381654729
|
  |
| Joined: 02 Mar 2008 |
| Total Posts: 16 |
|
|
| 11 Dec 2011 11:33 AM |
Will this work?
Workspace –Script1 –Model ––Script2 ––SomeBrick
Script1: game.Workspace.Model.SomeBrick:Destroy()
Script2: function onChildRemoved(child) print(child.Name) --or whatever other code end script.Parent.ChildRemoved:connect(onChildRemoved)
Because apparently if something is Destroy()-ed, it can't be used anymore? |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 11 Dec 2011 11:51 AM |
I'm not entirely sure...you can test it out, or just:
game.Workspace.Model.SomeBrick.Parent = nil |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 12:27 PM |
| Destroy works just like Remove |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 11 Dec 2011 12:29 PM |
"Destroy works just like Remove"
What was the point of them adding it in then? |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 11 Dec 2011 12:31 PM |
@UFAIL Destroy() eliminates all traces of the object, while Remove() just parents it to nil. |
|
|
| Report Abuse |
|
|
Pyzothon
|
  |
| Joined: 26 Oct 2011 |
| Total Posts: 822 |
|
|
| 11 Dec 2011 12:32 PM |
I heard in Scripters that :Destroy() completely gets rid of an object, whereas :Remove() just sets the object and its children to nil.
Pyzothon, novice scripter/programmer. |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 12:36 PM |
*tracks thread*
-Certified Idiot: Class 3.7 |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 12:38 PM |
Are they keeping :Remove() and just replacing it with :Destroy()? Or are they removing it?
~Cows go MOOO, Ducks go quack, Bikerking200 goes Mommy?~ ~Do what I say or Die~ |
|
|
| Report Abuse |
|
|
Pyzothon
|
  |
| Joined: 26 Oct 2011 |
| Total Posts: 822 |
|
|
| 11 Dec 2011 12:44 PM |
:remove() is deprecated but can still be used, :Remove() and :Destroy() aren't deprecated and both work.
Pyzothon, novice scripter/programmer. |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 12:45 PM |
So there're not removing :Remove()?
~Cows go MOOO, Ducks go quack, Bikerking200 goes Mommy?~ ~Do what I say or Die~ |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 12:54 PM |
| That's odd, why did they add :Destroy()? |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 11 Dec 2011 12:57 PM |
@Pyzothon
:remove() and :Remove() are the same exact things. |
|
|
| Report Abuse |
|
|
Pyzothon
|
  |
| Joined: 26 Oct 2011 |
| Total Posts: 822 |
|
|
| 11 Dec 2011 01:07 PM |
@Flurite
When did I say they aren't?
Pyzothon, novice scripter/programmer. |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 01:19 PM |
@Pyzothon So basically :Destroy() is more efficient? As in trying to reduce lag |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 11 Dec 2011 01:37 PM |
@Pyzothon
":remove() is deprecated but can still be used, :Remove() and :Destroy() aren't deprecated and both work."
You said it was deprecated, then you said it wasn't. |
|
|
| Report Abuse |
|
|
Anaminus
|
  |
 |
| Joined: 29 Nov 2006 |
| Total Posts: 5945 |
|
|
| 11 Dec 2011 02:24 PM |
Seems like lot of people are confused. Here's what each function actually does:
Remove: Sets the object's Parent to nil, and calls Remove on each of the object's children. This basically means that Remove is called on all descendants of the object.
ClearAllChildren: For each of the object's children, ClearAllChildren is called on the child, then the child's Parent is set to nil.
Destroy: Sets the object's Parent to nil, locks the object, and calls Destroy on each of the object's children. When the object is locked, attempting to set its Parent throws an error. |
|
|
| Report Abuse |
|
|
Merely
|
  |
| Joined: 07 Dec 2010 |
| Total Posts: 17266 |
|
|
| 11 Dec 2011 02:33 PM |
@Anaminus
Thanks.
By the way, is it true that you figured out how to call LoadAsset on the same Id multiple times without caching the results? If so, how did you do it? |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 07:50 PM |
"Destroy works just like Remove"
Wrong.
It puts the object in nil, disconnects all its events, locks its parent, removes some of its internal functionalities (C side) and then calls itself on all the children of that object.
It does more things than Remove.
Anyways, Remove is deprecated, so just use Destroy. :)
"Are they keeping :Remove() and just replacing it with :Destroy()? Or are they removing it?"
They're keeping it, but they deprecated it, so you shouldn't use it. They didn't remove it so scripts that use it still work, but don't use it in new scripts.
":Remove() and :Destroy() aren't deprecated and both work."
Wrong. :Remove() _IS_ deprecated. Look in the object browser...
"So there're not removing :Remove()?"
They're not removing it, but don't use it in new scripts. They won't update Remove or take it into consideration anymore, if you still use it, you're going to get trouble.
"ClearAllChildren: For each of the object's children, ClearAllChildren is called on the child, then the child's Parent is set to nil."
That's why I think it should be called ClearAllDescendants instead.
"Destroy: Sets the object's Parent to nil, locks the object, and calls Destroy on each of the object's children. When the object is locked, attempting to set its Parent throws an error."
Actually, it sets the object's parent to nil, locks it, disconnects all its connections, disables some of its C side functionalities and then calls Destroy on each children of the object. |
|
|
| Report Abuse |
|
|
HatHelper
|
  |
 |
| Joined: 02 Mar 2009 |
| Total Posts: 46305 |
|
|
| 11 Dec 2011 07:54 PM |
Why does it matter if its deprecated? If they are never removing it, why not use it anyway? isn't getChildren() deprecated? |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 07:58 PM |
"Why does it matter if its deprecated? If they are never removing it, why not use it anyway? isn't getChildren() deprecated?"
Because they're not taking it into consideration anymore. They're not going to update it anymore either. They're going to act as if it didn't exist, except they're still keeping it for old scripts to work.
The only reason they're keeping it is so old scripts still work.
Also, Destroy manages the memory in a better way, as it disconnects events and also even removes ambiguity. Using Remove is just running into trouble.
Destroy is better than Remove and it isn't deprecated. That's why you should use it. |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 08:00 PM |
| That sucks. Seems as if I must edit lots of my scripts if I want them to be 'up to date'. |
|
|
| Report Abuse |
|
|
HatHelper
|
  |
 |
| Joined: 02 Mar 2009 |
| Total Posts: 46305 |
|
|
| 11 Dec 2011 08:01 PM |
Hm. What about when removing HopperBins? I'll use Destroy() when I know I'll never see that Instance again :I |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 08:04 PM |
"Seems as if I must edit lots of my scripts if I want them to be 'up to date'."
You don't need to update your old scripts. But don't use Remove in new scripts. Also, if in any of your places, you use Remove to remove a lot of parts, you should replace it by Destroy. But other than that, don't bother editing all your scripts to use Destroy. Just don't use Remove anymore in the future.
"What about when removing HopperBins? I'll use Destroy() when I know I'll never see that Instance again :I"
Why would you use Remove instead of Destroy? What's wrong with Destroy? It takes one more letter to type. YOU DON'T NEED TO EDIT YOUR OLD SCRIPTS! You just need to use Destroy in the future... What's wrong with using Destroy instead of Remove? It doesn't require any more work and it's more efficient and is better at managing memory...
What's the point of using Remove when you can use Destroy? Only to type one less letter? Only because your fingers are less used to typing Destroy than typing Remove? No, seriously, why would you use Remove when you can use Destroy? |
|
|
| Report Abuse |
|
|
HatHelper
|
  |
 |
| Joined: 02 Mar 2009 |
| Total Posts: 46305 |
|
|
| 11 Dec 2011 08:09 PM |
"YOU DON'T NEED TO EDIT YOUR OLD SCRIPTS!"
Then why edit my mind to change my future scripts. What's the point(that I'd care about) of using destroy() over remove()? |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 09:20 PM |
...
Here is what happens: remove became deprecated, Remove isn't deprecated, Destroy was added.
The Remove method parents the object to nil where it can still be used and manipulated. The Destroy method deallocates the object on the C-side. |
|
|
| Report Abuse |
|
|