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 |
|
|
| |
|
|
| 09 May 2015 08:56 PM |
| You don't need to. You can just use ClearAllChildren() which is much easier. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| Joined: 01 Feb 2015 |
| Total Posts: 486 |
|
| |
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 09 May 2015 09:05 PM |
| You know that OP posted a request for it to only delete children named Punches, right..? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 09 May 2015 09:09 PM |
| @cnt, that will destroy everything in Workspace... |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 09 May 2015 09:17 PM |
@Cease, no really!!
Go back to RbxDev, oh wait. |
|
|
| Report Abuse |
|
|
| |
|
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 |
|
|
|
| 10 May 2015 10:50 AM |
| @kub, I was in it, but I got banned. |
|
|
| Report Abuse |
|
|
|
| 10 May 2015 10:50 AM |
| @kub, PS, thanks for trying to defend me. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|