I usually use task.spawn
to make a new thread, but sometimes coroutine.wrap
. My scripting inconsistent made me realize, what’s the difference between task.spawn
and coroutines?
4 Likes
Coroutines you can stop and start with the script, but task.spawn will just run until all the code has been executed.
12 Likes
There isnt really a difference, but spawn() has a built in wait() into it before the code within it executes. Whereas coroutine executions are instantaneous.
And like @Orbular3 said. You can stop and resume a coroutine. You cannot with spawn()
6 Likes
Any difference performance wise?
spawn()
(or the new task.spawn()
) will fire code immediately.
spawn()
is deprecated, and task.spawn()
should be used to enhance performance
overall, there isn’t a performance difference, coroutines
fire code alongside a thread, task.spawn
does it with the engine sheduler.
5 Likes