✓ Accepted answer
#It's a Hack.
I don't mean a hack as in exploits or whatever, but a hack is in a trick. while wait() do abuses the fact that wait returns a number (it actually returns two), the first one corresponding to the time Roblox yielded the thread for. Since in Lua, truthy values are anything that is not false or nil, and numbers are not false or nil, the number returned is abused as a condition. If wait were to not return anything, or if it returned a falsey value, you could not use it as a condition. It's somehow dependent on wait returning a truthy value.
#Readability.
You should use
while true do
wait(t)
end
It's clearer. It's also more logical, it tells you that the loop's condition is true, and that it does not necessarily have a terminating condition. It makes zero sence to use a number as a condition. This can be interpreted as do this forever, as the loop's condition is always true and therefore is an infinite loop.
Use while true do wait(t) ... end, for these reasons.
10 comments
use while true do, instead of while wait(1) do
https://docs.google.com/document/d/1ieZ8OzXPiXe3R7rs_xWmYZOnhQevlagN0ZWwoj_zKP4/edit
wait will not return False, and it's used by a ton of commercial software but this entire website insists to use while true...don't really matter though
^^^
That doc was made by a moderator
a staff member I mean
https://scriptinghelpers.org/questions/69185/break-function-not-properly-breaking-loops#66215 read my answer for more info.
it's up to opinion, you can even do
while wait(1) and true dowhich obviously doesn't matter for this but is useful when you have a conditionI would use while wait() do because I don't wanna put while true do and forget about the wait()
bad greatneil80