Why is wait() important?

Yes, it’s logged here

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.

1 Like

So same functionality, just not recommended.

Honestly, I don’t think any ROBLOX game’s server will run for long enough to have the wait() affect anything crucial unless you just…don’t code properly. But I’ll start using task.wait() if it really makes that much of a difference.

1 Like

while wait is a bad idiom (search that up)

You can use that function to prevent script overload when you are using loops. It can also be really useful for timing things right or once everything is loaded in. Because problems can happen if the player isn’t loaded or something else.

I didn’t say they don’t wait the same time. I said that a while wait() do will wait BEFORE the code block executes where while true do executes the code block and then waits.

It’s just a question of placement.

This results in the same code, this is the same example you quoted in the original reply.

while true do
    task.wait()

    -- Code
end

while task.wait() do
    -- Code
end

Both of these would run the wait first.

What wouldn’t is this:

while true do
    -- Code

    task.wait()
end

This is literally what I said in my first message. I just didn’t provide a code example. I also probably could have explicitly said if you place the wait at the end.

?
You quite literally said that using while true do wait() --Code end would run code before waiting.

More specifically, you originally said “the second block would wait before running code”, the second block in the post you replied to, is this:

And you claimed the other block, (which is while true do wait() -- Code end) would run code first and then wait, which isn’t the case.

I guess I didn’t read his code fully or he edited to add the --code comment, because I didn’t see that before.