killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
|
| 17 Dec 2011 06:15 PM |
| If so, why? What can each do differently than the other? |
|
|
| Report Abuse |
|
|
mage11561
|
  |
| Joined: 03 Sep 2008 |
| Total Posts: 13217 |
|
|
| 17 Dec 2011 06:26 PM |
Yes, :Remove() just nils the Parent and its children. :Destroy() completely gets rid of it. |
|
|
| Report Abuse |
|
|
iamogggg
|
  |
| Joined: 09 Sep 2008 |
| Total Posts: 642 |
|
|
| 17 Dec 2011 06:31 PM |
Depends on what you're trying to do. Generally, yes, unless you want to access the object after you get rid of it.
But if you wanted to do that, you could just use .Parent = nil |
|
|
| Report Abuse |
|
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
|
| 17 Dec 2011 06:37 PM |
| Can you give an example of where i would want to access the object after i got rid of it? |
|
|
| Report Abuse |
|
|
iamogggg
|
  |
| Joined: 09 Sep 2008 |
| Total Posts: 642 |
|
|
| 17 Dec 2011 06:41 PM |
| Very rarely. For example, I made something where it "rewinds" time, and the script has a table with a key of every object in the workspace. If someone pushed a block off of the edge of the map, and it got removed, I wanted to be able to fetch it, Parent it back into the workspace, and move it to its original position. |
|
|
| Report Abuse |
|
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
| |
|
|
| 17 Dec 2011 06:44 PM |
| Remove just sets its parent and its descendants parents' to nil. Destroy does the same, however it locks the object too, which means you cannot set its parent anymore. Therefore its parent will remain nil forever now. |
|
|
| Report Abuse |
|
|
iamogggg
|
  |
| Joined: 09 Sep 2008 |
| Total Posts: 642 |
|
|
| 17 Dec 2011 06:58 PM |
| Weelll.. no. It doesn't just do that. It actually DESTROYS the part. It's not in "nil," it just doesn't exist. |
|
|
| Report Abuse |
|
|
Wil2
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 728 |
|
|
| 17 Dec 2011 07:01 PM |
nil = nothing if something is nil, it doesn't exist. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 17 Dec 2011 07:23 PM |
Ahem.
local p = Instance.new("Part") p:Destroy() print(p) print(p.BrickColor)
>Part >Medium stone grey
No, it sets the parent and then locks it. |
|
|
| Report Abuse |
|
|
|
| 17 Dec 2011 07:25 PM |
| @swmaniac: Is that not exactly what Remove does? :l |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 17 Dec 2011 07:26 PM |
| The difference between :Destroy() and :Remove() is that after calling Destroy, the parent property is locked, attempting to set it gives an error. |
|
|
| Report Abuse |
|
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
| |
|
cool12309
|
  |
| Joined: 21 Sep 2008 |
| Total Posts: 1442 |
|
|
| 17 Dec 2011 10:02 PM |
I don't know, but just use what you plan to do.
If you plan to re-use it later, use :Remove() If you don't, use :Destroy()
End. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 17 Dec 2011 10:06 PM |
@Cool
Uh, .Parent = nil should be used for what you called :Remove() cases. :Remove() should not be used at all anymore. To quote a mod:
"There are two things that could be considered removing, Removing the object from the game temporarily so that physics aren't used on it; it can be placed back into the game later; Deleting an object.
Remove did neither." |
|
|
| Report Abuse |
|
|
Varp
|
  |
| Joined: 18 Nov 2009 |
| Total Posts: 5333 |
|
|
| 17 Dec 2011 10:48 PM |
Use Obj:Destroy() if you want to destroy an object. Use Obj.Parent = nil if you want it to go away, but not forever.
Don't use Obj:Remove() in new scripts because it is deprecated. |
|
|
| Report Abuse |
|
|
|
| 17 Dec 2011 11:52 PM |
| since when did :Destroy() come out? -.- |
|
|
| Report Abuse |
|
|
|
| 18 Dec 2011 12:03 AM |
"Depends on what you're trying to do. Generally, yes, unless you want to access the object after you get rid of it."
You shouldn't use Remove on an object if you want to use it later. Even if it works, you're not supposed to.
In fact, you wouldn't be supposed to anyways since Remove is deprecated, but EVEN if it wasn't, you still wouldn't be supposed to.
"Remove just sets its parent and its descendants parents' to nil. Destroy does the same, however it locks the object too, which means you cannot set its parent anymore. Therefore its parent will remain nil forever now."
Destroy does more things than that. It also removes connections and does some other things.
"Weelll.. no. It doesn't just do that. It actually DESTROYS the part. It's not in "nil," it just doesn't exist."
Wrong. Using Destroy on a part doesn't deallocate it.
"No, it sets the parent and then locks it."
And removes connections, and destroys some of the functionalities of the object, and calls itself on all the children.
"Which is quicker?"
Destroy, by far.
"If you plan to re-use it later, use :Remove()"
Wrong. Wrong wrong wrong. If you want to use it later, you don't want to remove it, you just want to set its parent to nil temporarily. And anyways, Remove is deprecated, so you shouldn't use it. |
|
|
| Report Abuse |
|
|