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() :Destroy() :Kick()

Previous Thread :: Next Thread 
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 May 2014 03:23 AM
:remove()

Never use, deprecated, unnessecary lag if used a lot.
This accomplishes the same thing as :remove()

brick.Parent = nil

Wiki notes:

Deprecated:This item is deprecated. Do not use it for new work. Use ClearAllChildren to get rid of all child objects, or Destroy to completely destroy this object and its descendants. If you have to remove an object from the game, and you must return it again later, set its Parent property to nil.

This method sets this object's Parent property to nil, then calls Remove on each of the object's children, such that the hierarchy of the object is destroyed. However, the object and its original descendants are still useable, if referenced.
Due to confusion with its behavior, Remove has been deprecated and replaced by two other methods. One is Destroy, which performs the intended behavior of removing the object and ensuring that it cannot be used afterwards. The other is ClearAllChildren, which functions in a way similar to Remove, but with a name that better describes its behavior.



:Destroy()

Will get rid of the brick called on, it disconnects ALL events.

Wiki notes:

Sets the Parent property to nil, locks the Parent property, disconnects all connections and calls Destroy() on all children.



:Kick()

Use to get rid of players from a game. Neither of the above will disconnect them. This will.

Wiki notes:

Kicks the player from the game, forcing them to leave. This will actually disconnect the player from the server.





Now, no more arguments.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 May 2014 03:43 AM
Bump to make sure people see this.
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
06 May 2014 03:48 AM
Another way to disconnect a player is to parent there player to nil, then parent it back to players.
Report Abuse
AetherShotgun is not online. AetherShotgun
Joined: 17 Mar 2014
Total Posts: 656
06 May 2014 03:50 AM
This isn't a question... in other words, I believe this is the wrong forum.
Report Abuse
stickmanx25 is not online. stickmanx25
Joined: 17 Aug 2007
Total Posts: 5829
06 May 2014 03:51 AM
Shame. :(

Any word on why, exactly :remove() causes performance issues and :Destroy() doesn't?
Report Abuse
KiwiTronik is not online. KiwiTronik
Joined: 18 Feb 2010
Total Posts: 3221
06 May 2014 03:59 AM
@Aethar

You're allowed to share your scripts :)

~I'm an Angry Llama~
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 May 2014 04:01 AM
@main

ERRRR Wrong. If you set your players parent to nil your not disconnected, and trying to reps rent it anywhere will error saying that the players parent property is locked.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 May 2014 04:01 AM
reparent*
Report Abuse
AetherShotgun is not online. AetherShotgun
Joined: 17 Mar 2014
Total Posts: 656
06 May 2014 04:02 AM
@Kiwi,

Oh dear me, excuse me, didn't see his one line of script... this is more like telling anyone who actually lurks the forums (mostly knowledgeable scripters) about something we all know. Just somewhat annoys me to read something that really isn't going to get used. But hey, if he wants to waste his time telling us all something we already know, i'm not going to judge.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 May 2014 04:04 AM
You don't all know this. Half the people I see on here uses :remove

To name a couple, viper, and KOT
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
06 May 2014 04:06 AM
g = game.Players.MainDirectory
g.Parent = nil
g.Parent = game.Players

just tested that works fine.
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
06 May 2014 04:07 AM
Oh and by the way, it crashed me. :P e.g. roblox api
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 May 2014 04:08 AM
They must have changed it :P

I tested last night and got an error.
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
06 May 2014 04:09 AM
Ah, well it's roblox. What can you expect. lol
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 May 2014 04:10 AM
Lol
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
06 May 2014 04:12 AM
I find this to be good for newer scripters to use as reference, whether it belongs in this forum... not so sure, but I feel as you should put more detail as to why remove will cause lag as to destroy will not, otherwise you leave the "New Scripter" wondering and that's not something that you want for people who are learning.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
06 May 2014 04:15 AM
Is it bad that I never knew Remove() destroyed the hierarchy of an object ... ?
:o


It doesn't make lag, but it is less efficient than Destroy() if you don't want to use the object again.
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
06 May 2014 04:17 AM
@Agent o: I never knew it caused lag, I was going by what op said. lol
Report Abuse
KiwiTronik is not online. KiwiTronik
Joined: 18 Feb 2010
Total Posts: 3221
06 May 2014 04:17 AM
@Aether

So if you already know, and dont want to "waste time", there is no need to bother coming to this thread, and posting :P

~I'm an Angry Llama~
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 May 2014 04:45 AM
If you use remove enough it WILL cause lag, as it is still in the game taking up unnessecary lag.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
06 May 2014 05:15 AM
GC takes care of it as long as you have no references to the object in any scripts.
So no, it won't still be in the game after GC is finished with it.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 May 2014 06:11 AM
GC?

Remove just parents it to nil, so it is still there.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
06 May 2014 06:17 AM
I've actually used collectgarbage() to successfully fix a problem before...
Report Abuse
KOzero is not online. KOzero
Joined: 11 May 2010
Total Posts: 1411
06 May 2014 06:56 AM
Listen to the wise mod boy...
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
06 May 2014 07:17 AM
GC = garbage collector

When something gets parented to nil, and there are no references to it (no variables or properties), it gets deleted from memory automatically by the Garbage Collector.
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