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 crash my studio?

the code is

while true do
if game.Players.NumPlayers == ("1")
then game.Players:ClearAllChildren()
end
end

After it crashes my studio ( after I put in test mode ) Any other script I put in Crashes it to (in test mode ) IT crashes it and allows no other script there, any help on the reason why it does this?

(P.S, I can re-load Roblox Studio and its the same problem with any script in test mode... )

1 answer

✓ Accepted answer

You need to put a wait()in there, otherwise it runs the code so fast it crashes. Put it right under the while true do.

3 comments

0

THANKS THIS REALLY DID HELP IT DOESNT CRASH IT :D

0

Glad I could help!

0

Actually, that's not why it crashes. All games work on an infinite loop. It crashes because you are blocking the thread scheduler, who it's waiting for the script thread to yield for it to run other threads like the studio UI. So if you don't allow it to move with other threads the program will freeze.

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