GetChildren (Method): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>LocalChum grammar |
>JulienDethurens Did some small changes. |
||
Line 8: | Line 8: | ||
{{clear floats}} | {{clear floats}} | ||
{{Example|Using GetChildren with a [[Loops#The_for_loop|for loop]].< | {{Example|Using GetChildren with a [[Loops#The_for_loop|for loop]].<code lua> | ||
local children = | local children = Workspace:GetChildren() | ||
for i = 1, #children do | for i = 1, #children do | ||
print(children[i].Name) | print(children[i].Name) | ||
end | end | ||
</ | </code>}} | ||
{{Example|It is highly recommended to use GetChildren with a [[Generic for]] | {{Example|It is highly recommended to use GetChildren with a [[Generic for|generic for loop]].<code lua> | ||
for index, | for index, child in pairs(Workspace:GetChildren()) do | ||
print("Index: ", index) | print("Index: ", index) | ||
print(" | print("Child: ", child) | ||
end | end | ||
</ | </code>}} | ||
[[Category:Methods]] | [[Category:Methods]] |
Revision as of 02:57, 18 January 2012
![]() | |
Returns | Table children |
Description: | Returns a read-only table of the object's children. |
Member of: | Instance |
Example
{{{1}}}
Example
It is highly recommended to use GetChildren with a generic for loop.
for index, child in pairs(Workspace:GetChildren()) do
print("Index: ", index)
print("Child: ", child)
end