Debris question

So Debris has a hardcoded limit of 1000 items, and as far as I can tell there’s no way to print out all of the instances inside of debris.

My question is that if you run Debris:AddItem() on the same object say 3 times, will it increment 3 instances in debris or will it keep it at only 1? I want to know if I should bother adding a check if an instance was already added to Debris or if the service already knows that instance was added and doesn’t increment.

This is relevant because I’ve created weapons that can hit hundred of parts at the same time (to clean them up I add them to Debris with a delay), and parts noticeably just disappear after firing it off only 3 times.

1 Like

Debris doesn’t really parent the added items to itself as I’ve ran :GetChildren() on it and it always returned 0, because it schedules the deletion of an instance (the documentation for Debris:AddItem() says it itself), basically the same as if you ran task.delay(3, instance.Destroy, instance).

So technically, no. Other than scheduling deletion for parts I’m not really sure how Debris works myself, but I’m assuming Debris still deletes the part the after the duration of the first :AddItem() called.

Edit:

I’m assuming Debris still deletes the part the after the duration of the first :AddItem() called.

I tested this hypothesis myself, with calling 2 :AddItem()s at the same time with varying durations, and it seems like Debris destroyed the one with the shortest duration first.

1 Like

Yeah Debris doesn’t parent to itself because it still leaves items at their original locations in the explorer, so I assume it adds some sort of tag to an item. I’m just trying to figure out if the service will add multiple tags to the same item if it’s ran multiple times on the same item, since only 1000 of these “tags” can exist at a time before Debris just instantly destroys any items added when the count is over 1000.

1 Like

You can put the same item in debris multiple times and it will count towards the 1000 limit.

For your problem I would recommend checking to see if your code correctly calls Debris:AddItem() the first time one of your weapons hits something. If you’re using raycasting to detect hit parts you can just take the instance from the RaycastResult and add it debris right off the bat. Other than that I can’t really help much since you didn’t provide any code

The code works just fine, here an example of what I’m talking about.


I’m assuming it’s occurring so quickly because it’s tagging the same objects more than once so I’m gonna add a check to see if they’re already tagged before adding them to debris.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.