API:Class/Instance/GetChildren

GetChildren

Function of Object Icon.pngInstance
array<Instance> GetChildren ()

Returns: array<Instance>
Description: Returns an array of the object's children.

Example

The below would print the name of all objects currently in Workspace when ran. In this example it's done using a for loop.

local children = workspace:GetChildren()
for i = 1, #children do
    print(i, children[i].Name)
end

It is recommended, however, that you use a generic for loop, as seen below.

for index, child in pairs(workspace:GetChildren()) do
    print(index, child.Name)
end