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 7 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:

1while true do
2    if script.Parent.Parent.TextLabel.Time == 50
3        then script.Parent.Visible = true
4        script.Parent.Parent.Warning.Visible = true
5    end
6end

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 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

1while true do
2    wait(.1)
3    if script.Parent.Parent.TextLabel.Time == 50
4        then script.Parent.Visible = true
5        script.Parent.Parent.Warning.Visible = true
6    end
7end
0
Oh, I see. Thank you for sharing this information. Michael_TheCreator 166 — 7y
0
I honestly can't believe I didn't catch that. Michael_TheCreator 166 — 7y
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 — 7y
Ad
Log in to vote
2
Answered by 7 years ago
1while true do
2wait()
3    if script.Parent.Parent.TextLabel.Time == 50
4        then script.Parent.Visible = true
5        script.Parent.Parent.Warning.Visible = true
6    end
7end

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