switch = 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 Used()

	if script.Parent.Flicked.Value == false then
		script.Parent.Flicked.Value = true
		local mod = switch
		local step = 1
		for i = 0, 2, step do
			rotateMod(mod, mod:GetModelCFrame(), CFrame.Angles(-0.2, 0, 0))
			wait()
		end
		game.Workspace.Glass.Cloister.Loop.Disabled = false

	else

		script.Parent.Flicked.Value = false
		local mod = switch
		local step = 1
		for i = 0, 2, step do
			rotateMod(mod, mod:GetModelCFrame(), CFrame.Angles(0.2, 0, 0))
			wait()
		end
		game.Workspace.Glass.Cloister.Loop.Disabled = true
	end
end

script.Parent.Use.MouseClick:connect(Used)


