Wait() vs task.wait()

I understand that task.wait() is the new way to wait, but why is that? I assume there’s some benefit over using simply wait()?

2 Likes

task.wait does not throttle, runs on 60 frames rather than 30, and it’s not deprecated.
(In general it’s faster and future-proof.)

3 Likes

In what way does wait() throttle?

1 Like

Over time it can change speed.

2 Likes

The following link may inform you about the diffrence between task.wait() and wait():

I hope it helps!

1 Like

wait() has inaccuracy time being put if you have printed the time, for example i want to set the time to 0.01 then the expected behavior is it should give us “0.01” when printed but this returns 0.03 so that’s what wait()'s biggest issue is.

here’s a comparison between these 2 functions. (as others said they’re just increasing a speed)

2 Likes

This was taken straight from: Task Library - Now Available!

task.wait() yields the current thread until the given duration (in seconds) has elapsed and then resumes the thread on the next Heartbeat step.

task.wait(5)
...

If no duration is given the duration will default to zero meaning the thread will automatically resume on the next step.

task.wait()
-- Equivalent to
RunService.Heartbeat:Wait()

task.wait() is an improved version of wait() as it schedules the current thread to be resumed after some time has elapsed without throttling.

You can basically say that wait() is deprecated and its better practice to use task.wait() in your scripts.

2 Likes