Spawn is evil? what do you think?

I recently came across this article. I still don’t fully understand it and would like to know what you think about avoiding the use of “spawn”. I only mean “spawn” and not “delay” or “wait”.

Personally I think that if we really shouldn’t use it, roblox would have already removed it. But I am really a beginner.

some extracts:

Roblox throttles resuming threads in a way that disproportionally negatively affects the use of these functions

spawn is especially evil because it seems innocent at first, but once your game becomes sufficiently complex with code that uses it, execution of items in the secondary queue can become significantly delayed. In worst cases, threads in the secondary queue can get deferred so long that they never even get the chance to run.

spawn allows wait to operate without delaying other things. Personally, I think its a good function to use.

I remember spawn() have a secret wait() function inside of it.

I didn’t used spawn before, when I make multiple threads, I always use coroutines.


Just use coroutines, spawn is part of Roblox’s old 30Hz, which gets clogged and you don’t have a guarantee that the thread will resume.

Just stick to coroutines, there is literally no point in using spawn.

1 Like

There’s no reason to use spawn when you can just use coroutine.wrap

-- code

You can use BindableEvents to spawn threads, like in Quenty’s fastSpawn module. It is a little more memory intensive since it has to create and destroy an instance but the thread begins on the same frame it is called and also prints the stack trace if it errors, so sort of a “best of both worlds” thing.


Plus, you can just create a utility module to emulate spawn.

local Utilities = {}

function Utilties.spawn(f)

return Utilities
local Utilities = require() — path to the utilities module.

    — code

1 Like

So far, we all agree not to use “spawn”, but why is it not yet marked as deprecated? Is it possible that it is still useful in some situation?

No, just use coroutines. There will never be a case where you’d have to use spawn over a coroutine.

Uh oh.
I use spawn and dont know how to use coroutines…

spawn() wont be deleted right??

1 Like

Using coroutine is very simple.
Maybe read this tutorial would help

no, spawn won’t be deleted, we just do not reccomend using spawn as there are better alternatives to spawn, therefore theres no real reason to use spawn over something like coroutine.wrap()