Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Explanation of destroy() please?

What does destroy mean?

3 answers

✓ Accepted answer

So;

:Destroy() Is a method you can use on any instance inside roblox, it's pretty self explanatory, it destroys the object. Once you destroy an object, you can not get it back, unlike the method :Remove(), which I'll explain later.

How to use :Destroy()...

So say you had a brick inside the workspace, named Part1. You could destroy the part like this:

workspace.Part1:Destroy()

Pretty simple right? Except you can't do something like this:

local s = workspace.Part1
s:Destroy()
s.Parent = workspace

That would throw an error at you. You could, however, do that with :Remove().

:Remove() is a method much like :Destroy(), except what remove does is parents the object to nil. nil is a word that basically means nothing, as in it parents the object to nothing, so we could re-parent it later.

Here's how you can use remove:

workspace.Part1:Remove()

So, just like destroy. Here's how you can get the object back into your game after you remove it:

local s = workspace.Part1
s:Remove()
wait(1)
s.Parent = workspace

That would remove the object from the workspace, wait 1 second, then make it come back, as if cloning it.

I hope I did alright at explaining this =) +1 my rep if I did.

Destroy removes the items and sets its parent to nil, removing the object and reducing lag

Remove just makes the items parent nil, letting all of the scripts inside still work and function like they would if it wasn't nil.

see an example write in the command bar

Workspace.(Name).Head:Destroy()

it destroys the head, this is the basic.

This discussion is preserved as it was. New answers, comments, and votes are closed.