GetChildren (Method)

From Legacy Roblox Wiki
Revision as of 00:10, 18 April 2023 by GuestIsJustBest (talk | contribs) (Fixing page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
GetChildren( )
Returns table
Description: Returns a read-only table of the object's children.
Member of: Instance
Example
Using GetChildren with a for loop.
local children = Workspace:GetChildren()
for i = 1, #children do
    print(children[i].Name)
end
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