Deeper Look into Wait()

Good point! Keep in mind Luau is almost entirely rewritten and has a lot of changes to standard Lua.

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.

2 Likes

That’s why I said a Big IF, its people mainly saying if it did or if it didn’t.

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 ^^

Almost everything that Roblox deprecates still works so that old games don’t break. They’ve just found a better way to do them.

Although when they got rid of TorsoMeshes a few years back it pretty much trashed some of the builds I was using them in.

1 Like

Dunno, I thought it already was.

As per:

Existing Methods

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 :slight_smile: )

1 Like

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.

1 Like

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.

1 Like

Curious, can you give an example of where ir would be useful? (Over os.time, tick, and clock of course)

I’m not sure, but I would probably use it for debugging. This timer would start once the thread has started.

I know it’s not the answer you want, but you could record the time beforehand…

local robloxStarted = os.time() - select(2,wait())

-- Other stuff here....
print(os.time() - robloxStarted)

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