Debris problems

Anyone else having problems with debris? for example if i do debris:AddItem(Tag,300) instead of destroying it in 300 seconds it destroys it in less than 30 seconds. Is there any solution rn?

5 Likes

yes I am having the same issue but I don’t have a fix , I’m trying to find one out

2 Likes

Debris service is pretty bad, you should make your own debris service module or use someone else’s. I made one recently DebrisService2 - Roblox

3 Likes

I have not checked whether I got the same issue but one possible solution is to have a script check the time a part is in game and then destroy it if it still exists after a specific time.

--a folder in which the part has been placed in
local folder = game.Workspace.PartsFolder
folder.ChildAdded:Connect(function(part)
    --create a coroutine (another thread) and run it
    coroutine.wrap(function()
        wait(300) 
        if part and part.Parent then
            debris:AddItem(part, 1) 
        end
   end)()
end)

I wouldn’t recommend using wait like that, and what’s the point of doing add item after the wait is already done?

If the wait period is 300 seconds and debris:AddItem() doesn’t wait longer than 30 seconds (As I have read in the post above, I haven’t tested this myself yet), using wait(300) will wait 300 seconds and destroy the part if it still exists

why not just use :Destroy() after?

What he meant to say is, whats the point of using debris:AddItem(part, 1) after wait(300) instead just use Instance:Destroy() as AddItem executes that internally after the delay is completed.

I tend to use debris:Additem in any case of destroying parts. Not sure whether this is a bad habit or not. It’s just what I prefer to use

That’s a very bad habit don’t do that

I’ve done some quick research and according to this post:

The main (and probably only noticeable) difference is the delay in debris:Additem() compared to the instant destroy using destroy() and the fact that the code will not break when using destroy() on a part which does not exist anymore

Using debris:AddItem(part, 0.001) works too. I’ve written 1 to have my explanation a bit more readable

1 Like

Please don’t tell people to do that, it’s one thing to have a bad habit but it’s another thing to tell people to do it as well

1 Like

I’m not sure how much better it is to use :Destroy() instead of debris:Additem() performance wise if you are 100% certain the part does exists.

Using debris:AddItem() is just the way I do it, :Destroy() works too if you know for certain that the part does exist and may indeed be a better solution.

Debris is used if you wanna delete something within a set time without causing any yield, If you wanna destroy something instantly the best course is to use :Destroy().

1 Like

im making this refit that uses :AddItem
so the thing is that i wanna easily delay the total destruction and death of the old part
if you instantly change a parent instantly after the parent was instantly changed then


just ignore the “exploiter” tag thing
i was making a remote function that puts a tag on your character called “exploiter”
if anyone fires the one remote function which isnt supposed to be invoked then it will put that tag on you but i was testing it and never disabled it lol

i use AddItem then 0.1 so it waits after itss changed so i can destroy it withhout having to add extra lines of code because trust me i use to do it the hard way for a long time