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 » Scripters
Home Search
 

Re: GetChildren():Destroy()?

Previous Thread :: Next Thread 
Qaynar is not online. Qaynar
Joined: 01 Feb 2015
Total Posts: 486
09 May 2015 08:55 PM
How do I get the children of something then get it to delete the children?
Report Abuse
XXahraternotXX is not online. XXahraternotXX
Joined: 03 Jan 2009
Total Posts: 221
09 May 2015 08:56 PM
model:ClearAllChildren()
Report Abuse
TheBenSquare is not online. TheBenSquare
Joined: 13 Dec 2009
Total Posts: 13604
09 May 2015 08:56 PM
You don't need to. You can just use ClearAllChildren() which is much easier.
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
09 May 2015 08:56 PM
ClearAllChilderen operates on remove with is depricated.
Use:

local ModelChildren = Model:GetChildren()
ModelChildren:Destroy()

ROBLOX ADD IT OR I SHALL STEAL YOUR TURKY SANDWHICH!!!!1111ONE!!
Report Abuse
Qaynar is not online. Qaynar
Joined: 01 Feb 2015
Total Posts: 486
09 May 2015 08:57 PM
how do I get it to delte only things with "Punches" name?
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
09 May 2015 08:58 PM
for _,v in ipairs(model:GetChildren()) do
if v.Name == "Punches" then
v:Destroy()
end
end

ROBLOX ADD IT OR I SHALL STEAL YOUR TURKY SANDWHICH!!!!1111ONE!!
Report Abuse
kubuto2 is not online. kubuto2
Joined: 16 Jul 2008
Total Posts: 1275
09 May 2015 08:59 PM
Apparently people don't know what GetChildren() returns.

GetChildren() returns a table filled with the objects children. If you do GetChildren():Destroy() your using the destroy method on a table which will error.

You have to iterate through the table to destroy it's children.

for _,v in ipairs(model:GetChildren()) do
v:Destroy();
end

http://wiki.roblox.com/index.php?title=API:Class/Instance/GetChildren
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
09 May 2015 09:00 PM
@kuboto i realized that and also with what he said
I then remade it
so maybe you should stay out and not make useless posts?

ROBLOX ADD IT OR I SHALL STEAL YOUR TURKY SANDWHICH!!!!1111ONE!!
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
09 May 2015 09:01 PM
>>if v.Name == "Punches" then

This line only destroys it if its name is "Punches", so you failed twice, sorry.
Report Abuse
Qaynar is not online. Qaynar
Joined: 01 Feb 2015
Total Posts: 486
09 May 2015 09:01 PM
ty @TheNewChicken
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
09 May 2015 09:02 PM
oh relly? he just thanked me.

ROBLOX ADD IT OR I SHALL STEAL YOUR TURKY SANDWHICH!!!!1111ONE!!
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
09 May 2015 09:03 PM
That's because he doesn't know how to script and doesn't realize that what you posted was a complete failure.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
09 May 2015 09:03 PM
Hooray

setmetatable(workspace:GetChildren(), {__index = {Destroy = function(self) for key, value in next, self do value:Destroy(); end end;};}):Destroy();
Report Abuse
TheBenSquare is not online. TheBenSquare
Joined: 13 Dec 2009
Total Posts: 13604
09 May 2015 09:05 PM
You know that OP posted a request for it to only delete children named Punches, right..?
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
09 May 2015 09:06 PM
Yes i do, and nQqzRYVpIKA5jLP still doesnt realise.

ROBLOX ADD IT OR I SHALL STEAL YOUR TURKY SANDWHICH!!!!1111ONE!!
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
09 May 2015 09:09 PM
@cnt, that will destroy everything in Workspace...
Report Abuse
Qaynar is not online. Qaynar
Joined: 01 Feb 2015
Total Posts: 486
09 May 2015 09:16 PM
Guys I can script a bit, I made this.... http://www.roblox.com/games/246186931/Qaynars-Place-Number-6
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
09 May 2015 09:17 PM
@Cease, no really!!

Go back to RbxDev, oh wait.
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
09 May 2015 09:18 PM
@cnt, what's that?
Report Abuse
kubuto2 is not online. kubuto2
Joined: 16 Jul 2008
Total Posts: 1275
09 May 2015 09:29 PM
@cntkillme Don't be mean now. Some of us can't get into it because people who can't script are taking up our slots.
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
10 May 2015 10:50 AM
@kub, I was in it, but I got banned.
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
10 May 2015 10:50 AM
@kub, PS, thanks for trying to defend me.
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
10 May 2015 10:58 AM
local h = whateveritis:GetChildren()
h:Remove









-Luminak I kind of like to program but i just [pst becaise i'm bortred right now and I don;'t know what to do so KI'm just posting but please reply to this it shoul dwork so blalhl blah and ya thats my story but wait I forgot plz send me trades because ?I like trading so please send trades yayaya abnd that stuff
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
10 May 2015 11:05 AM
@Lumiak, that actually wouldn't work. First off, :remove() and :Remove() are deprecated, but still usable. :GetChildren() returns a table full of the objects you call it on. So you would have to iterate through it and delete each one. However, :ClearAllChildren() does this, but is very bad because it calls :remove() instead of :Destroy().

So, you can use metatables to make ClearAllChildren call destroy rather than remove... OR:

local childs = obj:GetChildren();
for i = 1,#childs do
childs[i]:Destroy();
end


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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