Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I made this script where when you click the window it moves. How can I fix this?

Asked by 4 years ago

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)
0
Learn tweening. It moves objects to a certain position. That way you don’t have to do whiles or fors. SethHeinzman 284 — 4y
0
Also where is the function Lerp? SethHeinzman 284 — 4y
0
I put the Lerps in lines 11 and 17 aHumanWhoExists68 18 — 4y

Answer this question