Does spawn(function() create lag?

Hello, i use spawn function a lot in my script because i want my code to run simultaneously. The way i do this is

spawn(function()

wait(5)

print(hi)

end)

That is a simple example on how i use them. i know they have a tick of delay, and i know that coroutine is better, it would just be a mountain of effort replacing all my scripts with coroutine. I want to know if spawn is still good, and does not create lag (by this i mean lag that permanently stays, over the course of a server like while true do loops)

No it won’t, it will only start running a bit later when the game starts to lag, spawn doesn’t lag the game, that game lags it.

5 Likes

Spawning a function and wrapping it in a coroutine are essentially the same thing. The only difference (I believe) between the two is that coroutine’s will throw the task in the front of the line whereas spawning will place it towards the end.

So if there is any lag “caused” by spawning, the same amount of lag will occur when you wrap it in a coroutine.

1 Like