Uses of different "waits" in scripting

I am trying to make a function wait a few frames before destroying a particle system. I am rather new to Roblox and coding in general and as I was trying to find a solution, I have come across many different ways to make a script “wait” but I am unsure on when to use each one. ex: wait(), task.wait(), coroutines? Any help would be appreciated!

2 Likes

This thread will probably interest you but the tl;dr is that:
task.wait() updates x2 faster than plain ol’ wait. And is faster because of that. But if you don’t care too much about performance then I don’t think there’s too much of a difference.

1 Like

wait(x) runs at 30hz while task.wait(x) runs at 60hz. In most cases I’d use task.wait(x) because it’s faster than the original wait(x). task.wait(x) is also more accurate than wait(x) making it more effective for short timed events such as firing a gun. In your case, you’re simply destroying a particle system so either work but I’d honestly just use the new task.wait(x). Here’s a thread explaining all the other task operators if you’re interested in the task library.