Debris MaxItems still in effect despite being deprecated

For anyone interested, I’ve come up with a pretty elegant workaround to the problem I pointed out.

Since modules are effectively initialized as a unique script, we can leverage a ModuleScript to be a generator of external threads like so:

return task.spawn(function()
	while true do
		task.delay(coroutine.yield())
	end
end)

Then this generator can be resumed, to schedule new threads unassociated with the requiring script:

local ExternalThread = require(Module)
coroutine.resume(ExternalThread, LifeTime, Object.Destroy, Object)
-- Or alternatively
task.spawn(ExternalThread, LifeTime, Object.Destroy, Object)
1 Like

This is still relevant.


Having this weird behavior documented with one line at the bottom of the article (Debris | Documentation - Roblox Creator Hub) is unacceptable. This is incredibly frustrating to debug. I kept thinking my code was the issue, when it’s actually some obscure internal ‘optimization’ doing what it was coded to do.

Why is there a limit of 1k instances?

I’ve learnt my lesson now. Never using Debris again. I think there’s a ton of people that can run into the same issue. If you’re doing anything involving many instances (1K is not that much).

1 Like