generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: remove() vs. Destroy()

Previous Thread :: Next Thread 
koblaster456 is not online. koblaster456
Joined: 20 Jun 2009
Total Posts: 533
03 Apr 2012 12:50 AM
I don't get the difference!
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Apr 2012 01:00 AM
Destroy parents the object to nil and locks it and does other stuff? (calls remove on all children)

Remove parents the objecy to nil (calls remove on all children)


not a big difference. remove is faster
destroy does is slower[ makes it easier on garbage collecter?]

anyways remove is depricated but it really won't make much of a difference which you use
Report Abuse
qwerty1806 is not online. qwerty1806
Joined: 20 Sep 2008
Total Posts: 737
03 Apr 2012 01:35 AM
Use :Destroy(), :Remove() is no longer supported.
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Apr 2012 01:51 AM
You are able to use remove
its just depricated
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
03 Apr 2012 01:55 AM
Don't they have problems with capital lettres because it's case sensitive? I always write :remove() and it still works. I never used :Destroy().
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Apr 2012 02:10 AM
No, in fact Roblox uses PascalCase but you are still able to use many functions/methods in camel
Report Abuse
LPGhatguy is not online. LPGhatguy
Forum Moderator
Joined: 27 Jun 2008
Total Posts: 4725
03 Apr 2012 04:04 AM
Always opt for the PascalCase version, camelCase is deprecated.

Also, Remove doesn't completely wipe an object from memory. Don't use it.

Destroy wipes an object out. Use it instead.
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Apr 2012 12:33 PM
Destroy doesn't completly wipe the object from memory. . . It really hardly makes a difference which one you use
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
03 Apr 2012 02:27 PM
I believe Destroy eliminates all traces of graphical information (wire-frame, material textures, etc) from memory, but the userdata value still exists with all properties logged. But since it eliminates the graphics, you cannot re-parent the object to bring it back, and the Destroy method RobloxLocks the object (I think) to prevent re-parenting.
Report Abuse
LPGhatguy is not online. LPGhatguy
Forum Moderator
Joined: 27 Jun 2008
Total Posts: 4725
03 Apr 2012 02:28 PM
@Smurf279
No, it *does* make a difference. They do different things.

Remove puts an object in nil and nils all references.

Destroy destroys an object and nils all references.

Don't use Remove.
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
03 Apr 2012 02:29 PM
I'd agree with AgentFirefox there.

It's just better to use Destroy. If you DON'T want to get rid of the object and never parent it again, just set the Parent to nil instead. Don't even use 'remove' anymore. It's deprecated anyway
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
03 Apr 2012 02:31 PM
Well, as far as I know does remove only set the Parent to nil (which means that you can index it), while Destroy fully clears it from memory AND also makes it RobloxLocked. Calling anything on it will cause an error.

Beware to use Destroy(), because if you have a variable pointing to somethig destroyed, your scripts will crash if you use anything on it.
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
03 Apr 2012 02:36 PM
@jobro13 - I'm not sure about the memory part entirely. I'm pretty sure you can still index its properties.

Maybe it speeds up memory collection for it though. I have no idea how that works on the C-side of it all though.
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
03 Apr 2012 02:46 PM
@crazyman32: I bet it wont work.

Ill give you an example.

I am a really strange scripter and scripted a place that "SURVIVE THE BLOCK WAVE" and that spawns new bricks every frame. However, at the end of the line, all bricks destroy.

After a while, this server will be FULL of CLOG with the properties. Its not much for every part, only a couple of bytes, but that doesnt matter. If you do this a whole day, roblox server memory will be... kinda full. I dont think our ppl like that there memory is full, so it would be logically do delete the memory.

Another thing. Can you change values of RobloxLocked things? No, you cant.

I am SURE that Destroy() makes the object RobloxLocked. Can you change it? No.
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
03 Apr 2012 02:56 PM
remove() - If Im correct. remove doesn't exactly remove the model. It only makes its parent nil. It data is still contained in the level and may cause lag.

Destroy() - Again. Im not positive if im correct. But if I am it removes the model completely and gets rid of any trace of its existance. Except for Undoing.


Either one may be used. But ever since Destroy() came out I used that just to keep up to date with todays programming.
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Apr 2012 03:16 PM
"@Smurf279
No, it *does* make a difference. They do different things.

Remove puts an object in nil and nils all references.

Destroy destroys an object and nils all references.

Don't use Remove. "



"but it really won't make much of a difference which you use"
With either one you use you probably won't need to use the object again and all the extra steps Destroy takes does not really matter when the object is just going to get GC'd.
Besides they both get the job done and its not like :remove had any bugs to begin with
Report Abuse
Defendur is not online. Defendur
Joined: 31 Mar 2012
Total Posts: 40
03 Apr 2012 04:23 PM
... Enough confusion.

:Remove() makes the item nil.
:Destroy() makes the item nil and LOCKS all properties of it. (basically removes it from existance)
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
03 Apr 2012 04:24 PM
`:Remove()` parents the instance to nil and then recurses the function on all of the children of that instance.
`:Destroy()` does exactly the same thing as `:Remove()` however it RbxLock's it and breaks all connections with it.
`game.Debris:AddItem(instance,0)` garbage collects the instance and gets rid of all the memory of it.
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Apr 2012 04:51 PM
@SDuke

what? i tryed using game.Debris to get rid of objects in my 'Improved Instance' but you were still able to bring the object back into the game
also what exactly do you mean by connections in Destroy? I heard people say that but I wasn't really sure what connections was referring to
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
03 Apr 2012 05:23 PM
Event connections.
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
03 Apr 2012 06:02 PM
part:Remove()
part.Parent = workspace

That works.

part.Parent = nil
part.Parent = workspace

Accomplishes the same thing

However..

part:Destroy()
part.Parent = workspace

This will produce a error stating that the parent property of 'part' is locked.

:Destroy() wipes *most* memory that contains information about the destroyed about.

:Remove() accomplishes nothing more than setting the object's parent to nil.

Use :Destroy(). Don't use :Remove().
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
03 Apr 2012 07:02 PM
Heres my somewhat kiddy way of saying it

remove RE-MOVES it. Basically just moving it somewhere else. Its not gone

Destroy DESTROYS it completely.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image