GetChildren (Method): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Oysi93 We don't want people iterating with numeric for, do we now... |
>Camoy more solid article |
||
Line 1: | Line 1: | ||
<onlyinclude>{{Method | <onlyinclude>{{Method | ||
|name = GetChildren | |name = GetChildren | ||
|returns = [[Table]] ''children'' | |returns = [[Table]] ''children'' | ||
|description = Returns a read-only table of | |description = Returns a read-only table of the object's children. | ||
|object = Instance | |object = Instance | ||
}}</onlyinclude> | }}</onlyinclude> | ||
{{clear floats}} | {{clear floats}} | ||
{{Example|Using GetChildren with a [[Loops#The_for_loop|for loop]].<pre> | |||
local children = game.Workspace:GetChildren() | local children = game.Workspace:GetChildren() | ||
for | for i = 1, #children do | ||
print(children[ | print(children[i].Name) | ||
end | end | ||
</pre>}} | |||
{{Example|Using GetChildren with a [[Generic for]], high recommended.<pre> | |||
for index, object in ipairs(game.Workspace:GetChildren()) do | |||
print("Index: ", index) | |||
print("Object:", object) | |||
print(" | |||
print("Object:",object) | |||
end | end | ||
</pre>}} | </pre>}} | ||
[[Category:Methods]] |
Revision as of 12:34, 18 January 2011
![]() | |
Returns | Table children |
Description: | Returns a read-only table of the object's children. |
Member of: | Instance |
Example
Using GetChildren with a for loop.local children = game.Workspace:GetChildren() for i = 1, #children do print(children[i].Name) end
Example
Using GetChildren with a Generic for, high recommended.for index, object in ipairs(game.Workspace:GetChildren()) do print("Index: ", index) print("Object:", object) end