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 |
|
|
|
| 21 Sep 2011 04:43 PM |
| i beleive thats correct, never heard different |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|