Debris service or delay function?

Just curious, is it better to do

Debris:AddItem(Object, 10)
-- or
delay(10, function()
    Object:Destroy()
end)

I would use DebrisService just because it’s easier to manage and visualize. They do essentially the same thing and I believe there is really no difference in performance because they both run parallel to the rest of the script.

On the API for DebrisService they show how :AddItem mimics your delay() script and provides an advantage.

With that said, delay() would add customization such an effect upon destroying. If your goal is purely to destroy the object, use DebrisService.

3 Likes

Ye my goal was to have some way of detect when the part is destroyed. Seems like just extra code use Debris, but then also have a seperate function checking for it to be destroyed, which isnt always easy

I would use delay then and use either Signal or bindable events to send the alert when the object is destroyed! Or, you could put your debris items in a folder and connect a ChildRemoved event handler.