GetChildren (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>PilotLuke
No edit summary
>XLEGOx
No edit summary
Line 8: Line 8:


==Example==
==Example==
(Outdated example)
<pre>
<pre>


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


</pre>
</pre>
(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 04:03, 29 June 2008

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

Example

(Outdated example)


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

(More efficient example)

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