GetChildren (Method): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Camoy
fixed
>NXTBoy
Obviously examples can't use meaningful variable names...
Line 1: Line 1:
<onlyinclude>{{Method|name = GetChildren
<onlyinclude>{{Method
|arguments =  
|name                 = GetChildren
|returns = [[Table]] ''children''
|arguments           =  
|description = Returns a read-only table of this Object's children.
|returns             = [[Table]] ''children''
|object = [[Instance]]
|description         = Returns a read-only table of this Object's children.
|object               = Instance
}}</onlyinclude>
}}</onlyinclude>
{{clear floats}}
{{clear floats}}
Line 18: Line 19:
{{Example|<pre>
{{Example|<pre>
local children = game.Workspace:GetChildren()
local children = game.Workspace:GetChildren()
for i, j in ipairs(children) do
for index, object in ipairs(children) do
     print("index: ")  --j is the object, i is the index of the table it is at
     print("index: ",index)
    print(i)
     print("Object:",object)
     print("Object: ")
    print(j)
end
end
</pre>}}
</pre>}}

Revision as of 09:12, 26 October 2010

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

local children = game.Workspace:GetChildren()
for c = 1, #children do
    print(children[c].Name)
end

Example
local children = game.Workspace:GetChildren()
for index, object in ipairs(children) do
    print("index: ",index)
    print("Object:",object)
end