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.
Correction on this: wait() doesn’t even exist in original lua, I just realized this. Roblox made it, no wonder it didn’t work when I tried it outside luau.
Lua doesn’t even have any yielding functions if I recall. Either using a custom library or from scratch.
Is there a estimated time on wait()'s depreciation? On the docs it still doesn’t show as depreciated I believe.
ps. So siked a roblox staff guy here ^^
We will eventually mark the existing methods (spawn, delay, and wait) as deprecated in favor of their alternatives however they will continue to work as they do now for the foreseeable future and we have no plans to change this.
(That last part is pretty important, don’t let me scare you )
It’s really just a case of us marking them as deprecated in our documentation and advising users to use the alternatives under the task library. The task variants have a number of improvements so I would recommend using them over the yet-to-be-deprecated ones.
This doesn’t really matter. It will always perform the same and will probably never break.
Additionally, task.wait does not also return time yet, but wait does.
The differences between task.wait and wait are mainly that task.wait is more optimized and runs at 60 Hz (or whatever framerate the task scheduler is set to). The reason why it is optimized is a mystery to me, but I’d recon it’s because it only returns one value, unlike task.wait.
Wait is identical to wait. Spawn is identical to spawn.
The interesting part is that task.spawn is not a replacement for spawn. This is because spawn will wait until the next frame and then run the thread. This makes task.defer a replacement to spawn.
coroutine.resume and other thread functions are similar to task.spawn but wrapped in a pcall.
delay can almost directly be replaced by task.delay if I’m not wrong.
However, I wonder why we don’t have a task.time() yet. I’d prefer something like that to determine the number of seconds that has passed since a specified thread or current thread has started.