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

Why does this script make my studio crash when I test play the game?

Asked by 6 years ago

My studio and game was running completely smooth untile I decided to do a little work to a GUI in the game. After I made this change and I ran a test play in studio it made it crash. Also, when I try to actually play the game the game wont even load. When I remove this script, everything runs fine. Can someone explain?

Script:

while true do 
    if script.Parent.Parent.TextLabel.Time == 50 
        then script.Parent.Visible = true
        script.Parent.Parent.Warning.Visible = true
    end
end

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

If you make a while true do loop without any wait() in it, it will loop so fast it will crash studio!

Just add a wait into it. :P

while true do 
    wait(.1)
    if script.Parent.Parent.TextLabel.Time == 50 
        then script.Parent.Visible = true
        script.Parent.Parent.Warning.Visible = true
    end
end

0
Oh, I see. Thank you for sharing this information. Michael_TheCreator 166 — 6y
0
I honestly can't believe I didn't catch that. Michael_TheCreator 166 — 6y
1
I would recommend not making the delay .1, rather a smaller number, because .1 can be a large delay in some cases. obcdino 113 — 6y
Ad
Log in to vote
2
Answered by 6 years ago
while true do 
wait()
    if script.Parent.Parent.TextLabel.Time == 50 
        then script.Parent.Visible = true
        script.Parent.Parent.Warning.Visible = true
    end
end

You have to add that wait() there or else it loops infinitely without any waiting in-between which is too much for Roblox to handle

Answer this question