Okay, I made this script where when you click the window it moves upward or downward depending on it's position, and it doesn't work. The Output said "Unable to cast instance to CoordinateFrame"

Here is the script:

local part = script.Parent
local detector = part:WaitForChild("ClickDetector")
local opened = false
local one = script.Parent.Parent:WaitForChild("LerpTo1")
local two = script.Parent.Parent:WaitForChild("LerpTo2")

detector.MouseClick:Connect(function()
	if opened == false then
		for i = 0, 1, 0.5 do
			wait(0.5)
			part.CFrame = part.CFrame:Lerp(one, i)
			opened = true
		end
	else
		for i = 0, 1, 0.5 do
			wait(0.5)
			part.CFrame = part.CFrame:Lerp(two, i)
			opened = false
		end
	end
end)

3 comments

0

Learn tweening. It moves objects to a certain position. That way you don’t have to do whiles or fors.

0

Also where is the function Lerp?

0

I put the Lerps in lines 11 and 17