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: :GetChildren()

Previous Thread :: Next Thread 
Nagaris is not online. Nagaris
Joined: 18 Sep 2011
Total Posts: 422
21 Sep 2011 04:41 PM
This collects all of the children of the parent unless you are specific like: "game.Workspace:GetChildren("PartTypeA")" Right?
Report Abuse
Duderino99 is not online. Duderino99
Joined: 04 Aug 2009
Total Posts: 320
21 Sep 2011 04:43 PM
i beleive thats correct, never heard different
Report Abuse
Nagaris is not online. Nagaris
Joined: 18 Sep 2011
Total Posts: 422
21 Sep 2011 04:46 PM
Thanks.... Sorta new to scripting. I just wanted to make sure.
Report Abuse
xvgigakid is not online. xvgigakid
Joined: 22 Jun 2008
Total Posts: 4407
21 Sep 2011 04:51 PM
bob = a:GetChildren()

We just got all the children of 'a' and named it, 'bob'.

Now bob has been turned into a table value. Since it contains more than one object it would look something like this

bob = {a.Brick, a.Brick2, a.Brick3}

Now we use a for loop. we loop it to the ammount of values inside the table.

for i = 1, #bob do
print("Looped")
end

Now on a for loops first loop, i = 1, on its second loop it equals 2, on its third it equals 3 and so on.

to get the first value of a table we do

bob[1]

And you probobly get the rest.
So now lets get back to the for loop,

for i = 1, #bob do
print(bob[i].Name)
end

now since i is gonna equal 1, it qill get the first value of bob. Wich is, a.Brick,
It is now gonna print its name.

Say you want to check what it is,

for i = 1, #bob do
if bob[i].Name == "Brick1" then
print("Yes")
end
end

That is how to use GetChildren()
Report Abuse
Nagaris is not online. Nagaris
Joined: 18 Sep 2011
Total Posts: 422
21 Sep 2011 04:53 PM
Could you do

bob[1,2] to get the first two children of the table of bob?
Report Abuse
xvgigakid is not online. xvgigakid
Joined: 22 Jun 2008
Total Posts: 4407
21 Sep 2011 04:54 PM
Well...

You could get the children of Bob with a for loop. Except

Instead of doing this,

for i = 1,#bob do

Just do

for i = 1,2 do

But be sure to check if it exists before doing anything with the value.
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