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

How to remove a part after it has reach a certain Y position ?

Asked by
Vitou 65 Snack Break
9 years ago

Hello, I'd like to know why my script doesn't work.

local SnowFlake = script.Parent

if SnowFlake.Position.Y == -1
    then
    SnowFlake:Destroy()
    print("destroyed") -- DEBUG
end

SnowFlake (part) => Script (script)

Thanks

2 answers

Log in to vote
0
Answered by 9 years ago

The problem with this script is it only fires the if statement once. You have to have a loop. Also, I am sure that where the "then" was is not the proper context. Always put that after what you are testing.

local SnowFlake = script.Parent

while SnowFlake then
    if SnowFlake.Position.Y == -1 then
        SnowFlake:Destroy()
        print("Destroyed") -- DEBUG
    end
    wait()
end
Ad
Log in to vote
0
Answered by
Vitou 65 Snack Break
9 years ago

Thanks for helping ! How fool am I. :L

Answer this question