GetChildren (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Mr Doom Bringer
No edit summary
>Anaminus
No edit summary
Line 5: Line 5:
|returns              = [[Table]] ''children''
|returns              = [[Table]] ''children''
|description          = Returns a read-only table of this Object's children
|description          = Returns a read-only table of this Object's children
|object              = Global
|object              = [[Instance]]
|}}</onlyinclude>
|}}</onlyinclude>
|}
|}


==Example==
==Description==
(Simple example)
{{Example|
<pre>
<pre>
local children = game.Workspace:GetChildren()
local children = game.Workspace:GetChildren()
for c = 1, #children do
for num, child in pairs(children) do   -- pairs iterates through a table
     print(children[c].Name)
     print(num, child.Name)
end
end
</pre>
}}
==See Also==


</pre>
*[[Tables]]
(More efficient example)
<pre>
local children = game.Workspace:GetChildren()
for i, j in ipairs(children) do
    print("index: ")  --j is the object, i is the index of the table it is at
    print(i)
    print("Object: ")
    print(j)
end
</pre>

Revision as of 23:02, 24 October 2010

GetChildren( )
Returns Table children
Description: Returns a read-only table of this Object's children

Description

Example
local children = game.Workspace:GetChildren()
for num, child in pairs(children) do    -- pairs iterates through a table
    print(num, child.Name)
end


See Also