New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 8 days 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 268 — 8d
0
Also where is the function Lerp? SethHeinzman 268 — 8d
0
I put the Lerps in lines 11 and 17 aHumanWhoExists68 18 — 8d

Answer this question