According to the DevHub for the task (roblox.com) library,
task.spawn is meant as a replacement for something called “fast spawn.” If my memory serves it was meant to not mask errors and prevent throttling that
spawn was usually prone to do. The problem with fast spawn however was that it was kinda expensive due to utilizing
BindableEvents. In contrast, the
coroutine library is from vanilla Lua. They basically do the same thing, with the difference being that
task.spawn does not return any values while the coroutine library (
wrap) do. The biggest deal-breaker, however, is that the coroutine library can mask errors, so do take that into account whenever using them.
local function foo() return "bar" end print(task.spawn(foo)) print(coroutine.wrap(foo)()) -- bar print(coroutine.resume(coroutine.create(foo))) -- true bar