Whats actually the difference between task.wait() and wait() lol

ok so i’ve been using task.wait() for a while now just because everyone said to switch from wait() but honestly i never really understood why

like i just replaced all my wait()s with task.wait() at some point and moved on lol. does it actually do anything different or is it just the “newer” way of writing the same thing

-- i just use this now without really knowing why
task.wait(1)

-- instead of this
wait(1)

is there an actual performance difference or does it not really matter for small games? asking bc i wanna actually understand what im using instead of just copying what others do

1 Like

https://devforum.roblox.com/t/task-library-now-available/1387845

wait throttles at 30hz, meaning it will not leverage greater precision and can yield for longer than requested. task.wait leverages frame/simulation rate, which enables it to improve the accuracy at which your thread sleeps for the targeted amount of time.

7 Likes

task.wait basically doesnt care about lag, while wait does, if you lagged wait(1) would be more like 2 seconds, task.wait(1) would still be wait 1 second even if you lagged (thats what i understood of it atleast)

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.