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 while true crash my game?

i just dont understand it crashes my game

while true do
print'hello'
end

it shows me some kill script thing but how do i make while true do work without crashing my game?

1 comment

1

Please read the wiki before posting. This is very basic and is explained there.

2 answers

✓ Accepted answer

A while true do loop will not work without having a wait() in it because it would run way too fast and crash the game. You fix it by adding for example a wait(1):

while true do
wait(1)
print("Hello world!")
end

3 comments

0

This works fine, but if you'd want an constant loop you could just you wait() without any numbers. @Crispinus

0

thanks

0

you can also use wait(); It's the second fastest wait, the fastest being game["Run Service"].Heartbeat:wait(); which is 60 t/s

You can also do

while wait() do

end

, looks cleaner :)

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