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

Why is it considered bad practice to use "while wait()"?

As I understand it, doing

while true do
	--code
	wait()
end

is considered better than doing

while wait() do
	--code
end

Why is this?

4 comments

0

some how, some way the code structure of while wait() gives more strain to the game compared to otherwise.

0

to understand this ull most probably have to look behind the way roblox is designed

0

or who knows its probably just some conspiracy that roblox spread im not a professional

0

its just a bad habit to use while wait() do cuz it only runs fine on roblox.

1 answer

It isn't bad, people just say it's bad practice. wait() is a ROBLOX Lua function, the reason it works is because wait() returns values making it true. It's bad practice because if you were to move on from ROBLOX's engine, your loops wouldn't work because wait() wouldn't return anything.

I got this information from this video by ScriptGuider:

https://www.youtube.com/watch?v=QKR0jN52hvA

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