What is the difference between "remove()" and "destroy()"

Hey Devfourm, MisterSpeaks Here

What is the difference between “remove()” and “destroy()”
These two methods are very similar or exactly the same to my knowledge.
Could someone explain the difference between them if there is one?

4 Likes

They’re the same thing, Remove is just deprecated

deprecated? what do you mean by that?

1 Like

I assume you mean Instance:Remove() and Instance:Destroy().
Remove sets the parent to nil.
Destroy sets the parent to nil, disconnects all connections on the object’s events, and locks the parent property.

8 Likes

It’s discouraged for use in production

Yes, I am referring to Instance:Remove() and Instance:Destroy()
nil is just 0, right?
if it is then is there any way to recover it?
does it matter which one you use?

nil is nothing
0 is a number
not the same

4 Likes

so does it matter which one you use?

1 Like

use :Destroy() because :Remove() won’t get any more updates and is deprecated

7 Likes
6 Likes

Yes.
Remove is deprecated, and the alternative is just to set Parent to nil.
Setting the parent to nil allows you to access it later, so if you want to remove something, but add it back in later, set the parent to nil.
Destroy is for permanently getting rid of objects. Use destroy if you won’t use something later, as it prevents memory leaks.

12 Likes