Coroutine or delay

Coroutine.Wrap(function()) task.wait(time) end)() or delay(time, function()) end)

I’ve been using coroutines with waits in them wherever they are needed but forgot about the delay function and it’s much neater and doesn’t involve me resuming the coroutine or calling it or adding a extra wait line, should I start using delay instead?

I know they both have their own uses but this is specifically for times that waiting is needed without yielding the script.

https://developer.roblox.com/en-us/api-reference/lua-docs/task

what about using task.delay?

1 Like

Use coroutines if you need to start and stop them, use task.delay if you don’t need to start / stop it

1 Like

I didn’t realize this was added, thanks. I guess task.delay is a coroutine with a built in wait?

well I don’t know exactly what it uses, but it most likely has task.wait or a built in wait