door = script.Parent

function rotateMod(mod, center, rotation)
	local parts = {}
	local function scan(parent)
		for _, obj in pairs(parent:GetChildren()) do
			if (obj:IsA("BasePart")) then
				table.insert(parts, obj)
			end
			scan(obj)
		end
	end

	scan(mod)
	for _, part in pairs(parts) do
		part.CFrame = (center * rotation * (center:inverse() * part.CFrame))
	end
end

function onClicked()

	if script.Parent.Parent.Locked.Value == false then
		if script.Parent.Parent.RightOpen.Value == false then
			script.Parent.Parent.RightOpen.Value = true
			local mod = door
			local step = 1
			for i = 0, 20, step do
				rotateMod(mod, mod:GetModelCFrame(), CFrame.Angles(0, -0.075, 0))
				wait()
			end

		else

			script.Parent.Parent.RightOpen.Value = false
			local mod = door
			local step = 1
			for i = 0, 20, step do
				rotateMod(mod, mod:GetModelCFrame(), CFrame.Angles(0, 0.075, 0))
				wait()
			end
		end
	end
end

script.Parent.Parent.Clicker.MouseClick:connect(onClicked)