GetChildren (Method): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>NXTBoy
Obviously examples can't use meaningful variable names...
>Oysi93
We don't want people iterating with numeric for, do we now...
Line 17: Line 17:
</pre>}}
</pre>}}
*[[Generic for]] (More efficient example)
*[[Generic for]] (More efficient example)
*Highly recommended you use this one below.
{{Example|<pre>
{{Example|<pre>
local children = game.Workspace:GetChildren()
local children = game.Workspace:GetChildren()

Revision as of 18:41, 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

  • Generic for (More efficient example)
  • Highly recommended you use this one below.
Example
local children = game.Workspace:GetChildren()
for index, object in ipairs(children) do
    print("index: ",index)
    print("Object:",object)
end