Do multiple threads slow down roblox?

I have a minecraft like game and I want to update some blocks daily.
The way I do it is for each block:

function update()
--Do update stuff
task.delay(SECONDS_PER_DAY, update)

task.delay(SECONDS_PER_DAY, update)

Im wondering, is it less stressfull on the server if I instead put all daily update blocks into a list and loop through them one by one every day instead?

It depends on how many blocks there are. delay specifically, I don’t think is very performant to run repetitively.

Why not store all the created blocks, and then when a day elapses, iterate over all the blocks and run your updates on each one in that way?

Yeah that’s sorta the alternative…
Issue is, I’d still need to create a new thread for every block since not all of their update functions return instantly.

Also if one of them errors, the whole game fails.

There will be alot of blocks, but not all will have update functions.

If you’re using object-oriented design to represent your blocks, you could actually use BindableEvents probably.

Fire the event when ever a day elapses, and define a listener function for each block for the event, so when the event fires each block will update.


function block:Init()
--//New BindableEvent listener declaration here
updateBlock.Event:Connect(function() --//Event is invoked from another script when the day changes

It’s a more performant way of handling different processes or threads.

Would that be more efficient?
Is there any proof that it’s more efficient?

Using events is better than forcing a new thread or process to be ran using something from the task library, in my knowledge.

1 Like

Lets say you have 5000 blocks, idk whats better,
5000 threads waiting for their timer
5000 listeners waiting for a trigger to then :connect which is a new thread anyway, but it won’t live as long.


If you are instancing a lot of BasePart instances (blocks) which should be destroyed after some time has elapsed then use Debris:AddItem(Instance, Time) instead as it’s fitted for this purpose. Debris neither yields the current thread of execution nor does it create an additional unnecessary thread, all it does is marks an instance for its eventual removal once some duration of time has passed.