Debris:AddItem() is Destroying parts before it's time

https://gyazo.com/bf1d07cc4fa980658f4a502976e5eab6

If you observe closely you’ll see that a lot of my parts don’t make it out of the Frame meaning they got deleted, for some reason this happens only when I do Debris:AddItem(), does it have some sort of limit to how many Instances I can queue?

(No need to be concern about my Game running into performance issues)

I’m aware it’s deprecated, but it probably is in use. You can’t change it, but the limit’s there.

Your game is gonna run into performance issues :joy:

Debris.AddItem is programmatically equivalent to using delay and destroying the part after n seconds, where the passed function runs. Checks included.

delay(n, function()
    if part and otherChecks then
        part:Destroy()
    end
end)

The difference between AddItem and delay is that the former does not spawn a thread and it handles any cases on the backend.

That being said, like the above post suggests, MaxItems may still be in effect. Looking at the Gif closely when an iteration of your particles ends (0:02 to 0:03), the parts do go offscreen but there’s also less parts being spawned then.

You may want to consider your own mechanism for cleaning these parts up to avoid DebrisService’s limitations. If this behaviour is because of MaxItems, not sure why it’s still in effect if its deprecated.

Potentially relevant:

2 Likes