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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Destroy Got Children

Previous Thread :: Next Thread 
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 11:02 AM
Could I do GetChildren().destroy()? cos I really need to know, if not the how
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 11:06 AM
Also, how would I clone the Got Children?
Report Abuse
FoolHater is not online. FoolHater
Joined: 17 Jul 2008
Total Posts: 2141
13 May 2014 11:20 AM
local children = Workspace:GetChildren() --returns a table of children
for i = 1, #children do
children[i]:Destroy() --loops through table
end
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
13 May 2014 11:20 AM
i think you need to look into what :GetChildren() actually does and what it returns.

Report Abuse
FoolHater is not online. FoolHater
Joined: 17 Jul 2008
Total Posts: 2141
13 May 2014 11:23 AM
local children = Workspace:GetChildren() --returns a table of children
for i = 1, #children do
childcopy = children[i]:Clone() --clones each child in the table of children
childcopy.Parent = Workspace --cloned child is parented to the Workspace
wait(1)
end
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 12:03 PM
k, thnx... also, could I not do this?
ClonedParts = Workspace:GetChildren()
ClonedParts:destroy()?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
13 May 2014 12:08 PM
for I,v in pairs(ClonedParts) do
v:Destroy()
end

or you could simply

Workspace:ClearAllChildren()
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 12:11 PM
so ClearAllChildren :D thnx... btw, is thre a short way to copy children?
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 12:27 PM
plz answer
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 01:14 PM
bump
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
13 May 2014 01:19 PM
Here's what you wanted...


function CloneAllChildren(OldPar, NewPar)
for _,v in ipairs(OldPar) do
v:Clone().Parent = NewPar
end
end

CloneAllChildren(Workspace.Model, Workspace)


Or you could just clone the model itself...
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 01:45 PM
thnx, at lastsomeone answered! :D and also, can the clonechildren be done shorter like ClearAllChildren?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
13 May 2014 01:46 PM
Clone children isn't a method, it is a function. That I made.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 01:55 PM
oh... so it cant be 1 line :(
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 01:56 PM
also, do I rename the OldPar to the name of the Object that am gettin the Children from, and NewPar is were to paste it?
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
13 May 2014 02:00 PM
you can make anything one line.. even a 12000 line long script can be condensed into just one line...

Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
13 May 2014 02:00 PM
:ClearAllChildren()
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 02:02 PM
verified, then how would I do it?
and thnx desp, but islandmaker already told me about ClearAllChildren, thnx anyway :D
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
13 May 2014 02:03 PM
You can run a lot of things in one line but it's more organized to make multiple lines. Take the command bar for example.
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
13 May 2014 02:04 PM
im just saying that

while wait() do
print('examples');
end

can be condensed to

while wait()do print'examples'end

Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 02:06 PM
lol I knew it XD but was worth asking... but is there no shorter way to clone AllChildren than wat warspy said?
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
13 May 2014 02:07 PM
i dont get why why you it any shorter, its only like 7 lines...

Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 02:10 PM
my scripts are short... anyways, tell me, OldPar and NewPar, are they the Places of the cloned objects?
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
13 May 2014 02:11 PM
for i,v in pairs(parent:GetChildren()) do v:Clone().Parent = newpar end
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
13 May 2014 02:14 PM
lemme see... but is the starting locationf of the object in the brackets? cos if yes then y is it Parent?
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