----- door -----


interactive.ClickDetector.MouseClick:Connect(function()
	if doorOpen and not changingState and not doorLocked then
		changingState = true
		for i = 1, 12 do
			script.Parent:SetPrimaryPartCFrame(script.Parent.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(7), 0))
			wait()
		end
		changingState = false
		doorOpen = false
		lockInteractive.ClickDetector.MaxActivationDistance = 12
	elseif not changingState and not doorLocked then
		doorOpen = true
		changingState = true
		lockInteractive.ClickDetector.MaxActivationDistance = 0
		for i = 1, 12 do
			script.Parent:SetPrimaryPartCFrame(script.Parent.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-7), 0))
			wait()
		end
		changingState = false
	end
end)
