Task.wait , what is the smallest value that can be used?

Hi,

I am using task.wait in a loop and wondering what is the smallest valid value that can be used? (Not including 0 of course)

The API only says

’ Yields the current thread until the given duration (in seconds) has elapsed, then resumes the thread on the next Heartbeat step. The actual amount of time elapsed is returned’

Thanks

task.wait() yields for single frame, so at 60FPS that would represent a delay of roughly ~0.015 seconds. Bare in mind calling task.wait() with no arguments yields the thread for a single frame as well.

1 Like

if you leave the task.wait argument empty, it would be 0.03 seconds.

1 frame at 60 frames per second is 0.015 seconds, you’re thinking of “wait()”.

1 Like

oh yeah, 0.015 seconds

For task.wait(), it would yield the thread for 0.015 seconds. On the other hand, wait() would yield the thread for 0.03 seconds, which is why it’s better to utilize task.wait() vs wait().

It goes a lot further than just the timing. Wait is based on a legacy pipeline and will be deprecated in the future so it shouldn’t be used for new work. Task resolves a lot of problems and patterns with the current legacy equivalents and interfaces much better with the task scheduler. Additionally when deferred becomes the standard of scripting on Roblox you can be a bit more predictable about when your tasks are going to run and even push them to happen later rather than immediately.

2 Likes

So then it is never a exact set amount of time, since the FPS is client based? So different clients might have it the time different?

its very dependent on the situation if its “better” or not

Not even the situation, as @colbert2677 mentioned, wait() will become depreciated in the future, because it’s less predictable than task.wait().

There’s no reason to use wait() over task.wait().

all jokes aside i just prefer the readability of wait() rather than task.wait() and when coding casually and visualizing things if i need a wait to slow something down i will just shove a wait() in because its quicker to code than task.wait() (GOD FORBID I SPEND AN EXTRA SECOND TYPING OUT WAIT)

1 Like

Roblox autofill :star_struck: LOL