Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Explanation of destroy() please?

Asked by 10 years ago

What does destroy mean?

3 answers

Log in to vote
2
Answered by 10 years ago

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.

Ad
Log in to vote
0
Answered by 10 years ago

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.

Log in to vote
-1
Answered by 10 years ago

see an example write in the command bar

Workspace.(Name).Head:Destroy()

it destroys the head, this is the basic.

Answer this question