Which is better? Debris service or Instance:Destroy()?

Hello!

So I recently heard somewhere that the Instance:Destroy() function is soon to be deprecated and the Debris service is going to be taking over.

So instead of:

script.Parent:Destroy()

we need to be doing THIS:

game:GetService("Debris"):AddItem(script.Parent, 0.1)

Is this true or does it not matter which one you use?

Thank you for your replies and have a wonderful day! :slight_smile:

3 Likes

:Destroy() being deprecated doesn’t quite sound right, the methods you’re comparing have separate purposes. If you want to destroy an instance after x time you just use Debris.

2 Likes

I heard about Destroy being deprecated somewhere around the forum, and I think it’s similar to the wait() function, where you should use task.wait() instead.

1 Like

How when?? Remove() is deprecated in favor of Destroy it doesn’t make sense to deprecate such an important method.

4 Likes

I know, right? It didn’t make sense when I heard that, but I’m not sure if it’s true or not. Either way, I am just curious if one is better than the other. I think that are both good, though, for different things, correct?

1 Like

Well, Debris is just for convince, I use destroy to clear out memory (aka collecting garbage), but it’s up to you.

1 Like

I prefer to do basically the same: use :Destroy() to clear memory when Instances are not needed and use Debris when the Instance is not needed for the moment but might be required later.

1 Like

Depending on how many thing you want to destroy and if you are going to recreate similar parts, it might be more efficient to not destroy anything and simply cache and hide objects untill you use them again.
I.e if a player shoots rockets or something, insted of creating and destroying rockets all the time just move the exploded rockets to like x/y 9999999/999999 and then move them back when the player shoots them.

2 Likes

In my opinion, that’s the best way to use Debris.

2 Likes

If I’m going to destroy an object after a certain amount of time, then Debris could work.

If the object just needs to be cleared right then, use Destroy.

Caching parts can also be useful, but that’s whenever you would need to reuse certain parts.

4 Likes

@SpiritualSonicdash I agree with you!

Thank you everyone for your replies! Have a wonderful rest of your day! :slight_smile:

2 Likes

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