Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

3 comments

0

Oh, I see. Thank you for sharing this information.

0

I honestly can't believe I didn't catch that.

1

I would recommend not making the delay .1, rather a smaller number, because .1 can be a large delay in some cases.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.