What is Debris?

I have looked at the Debris page on the wiki, but I still don’t get when you would want to use Debris.

As far as I know, it it used to replace parts that were going to be destroyed, but was destroyed some other way so that the script doesn’t error, but I barely think that is often an issue.

Does anyone know how to use it and an example where you would want to use it?

2 Likes

The only method I use is :AddItem(toDestroy, time). I believe the wiki states this is the most efficient way to dispose of a no longer needed object, after X seconds have passed.

game.Debris:AddItem(workspace.Baseplate, 5) --//Remove Baseplate object after 5 seconds
7 Likes

An instance of Debris being superior to the standard timed destruction is when the object is unexpectedly destroyed prior to the timed destruction. If that’s the case, the code will error and stop the thread.

1 Like

I found information about Debris on the Developer Hub for you. I think this will help you get acquainted and find out what kind of service it is.

Link.

1 Like

its basically a better way of saying

wait(3) --wait 3 seconds
part:Destroy() --remove the part

as its only one line and doesn’t error when the specified part doesnt exist anymore.
example:

Debris:AddItem(part, 3) -- remove the part after 3 seconds
2 Likes

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

1 Like