Hi!
I’m not looking reignite the "while true do wait() vs while wait() do war", but I’m interested a couple of the things people have mentioned.
Is there a bug that causes wait() to return false? Some have said if wait() goes too fast it will return 0 and cause while wait() loops to break, however: print(0 and true) → true
[The loop will continue, regardless of having 0 returned to it]
Can wait() experience anomalies where it may never return?
Can wait() be delayed to the point it will error? Using different methods, I’ve been unable to cause wait() to timeout.
Do any of the above questions apply to other wait methods, such as: task.wait(), [event]:Wait()?
ps. If you have a comment not directly related to the above Qs, please Direct Message me.
Who said that?? wait() will always return 0.03, that is it’s default value, it is either that or 0.3.
Though, I highly recommend using task.wait() it runs on 60fps unlike wait() which runs on 30fps. Plus it’s future-proof meaning wait() might get deprecated.
Wait() can cause lag issues. If you’ve ever seen a player moving then pause and appear somewhere else 3 seconds later you’ve seen it.
I’d think it would be more a timeout for the wait issue. @weakroblox35 I’ve seen many posts that talk about wait() taking more than .03 seconds.
Please DM me if you have a response not in direct response to the questions. I know not to use wait, however i’m interested in any rare bugs that might be present.
wait() will not return any bugs, it will always return 0.04264230000262614 17288.045851547155 as shown above, if you want a future-proof and faster “loop” you can use task.wait().
plus wait() will never return booleans only numbers.
Exactly, there are however a lot of people who use the argument of wait() possibly returing false as a reason not to use while wait() do.
I’ve experience pretty bad engine bugs before, and wouldn’t be surprised if wait() also has some.
Who told you it will return false? Have you seen it in the official documents? I have never seen a function that is meant for numbers return a boolean evevr.
while true do
wait()
print("lol")
end
-- is the same as
while wait() do
print("lol")
end
Officially there should be no reason to return false. I’m saying that some in the community believe wait() can rarely return false [this could be due to a bug], and I’m interested in if there is one.
No, but it can last longer than the number you give it if it’s being throttled
If “it” is wait, then no
No, but you should probably use task.wait() instead (I forget if we deprecated wait() or not, but I can’t think of any good reason you’d want to use it)
You use while true do to determine if the condition is true, while wait() do will do the same thing but (this is a IF according to many posts, which doesn’t mean its true) if it returns false, it will break, from what I see is just IFs, not it does, or it will, its mainly just them saying potentially if roblox made it return false.
task.wait(0.03) will probably get you what you want, I don’t know if I would want to be beholden to throttling I don’t control to such a degree as a developer
I don’t think it has anything to do with any potential bug/breakage (there’s no chance we’d ever make wait() return a falsy value especially given the prevalence of while wait() do), but simply that while wait() do looks kinda weird. I don’t like abusing truthiness like that, but it will never break.