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’
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.
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.
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)