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

Why does this script crash my studio?

Asked by
IcyEvil 260 Moderation Voter
10 years ago

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

Log in to vote
1
Answered by 10 years ago

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.

0
THANKS THIS REALLY DID HELP IT DOESNT CRASH IT :D IcyEvil 260 — 10y
0
Glad I could help! CardboardRocks 215 — 10y
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. Destrings 406 — 10y
Ad

Answer this question