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

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

Asked by 5 years ago

This question already has an answer here:

Why is using wait() as a condition in loops shunned?

As I understand it, doing

while true do
    --code
    wait()
end

is considered better than doing

while wait() do
    --code
end

Why is this?

0
some how, some way the code structure of while wait() gives more strain to the game compared to otherwise. TheluaBanana 946 — 5y
0
to understand this ull most probably have to look behind the way roblox is designed TheluaBanana 946 — 5y
0
or who knows its probably just some conspiracy that roblox spread im not a professional TheluaBanana 946 — 5y
0
its just a bad habit to use while wait() do cuz it only runs fine on roblox. greatneil80 2647 — 5y

Marked as Duplicate by User#24403

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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

Ad