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