GetChildren (Method): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Camoy added |
Fixing page |
||
(22 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
<onlyinclude>{{Method | |||
| name = GetChildren | |||
| | | returns = {{type|table}} | ||
| | | description = Returns a read-only {{type|table}} of the object's children. | ||
|description = Returns a read-only table of | | object = Instance | ||
|object = | }}</onlyinclude> | ||
{{clear floats}} | |||
{{Example|Using GetChildren with a [[Loops#The_for_loop|for loop]].<syntaxhighlight lang="lua"> | |||
local children = Workspace:GetChildren() | |||
for i = 1, #children do | |||
print(children[i].Name) | |||
local children = | |||
for | |||
print(children[ | |||
end | end | ||
</syntaxhighlight>}} | |||
</ | {{Example|It is highly recommended to use GetChildren with a [[Generic for|generic for loop]].<syntaxhighlight lang="lua"> | ||
for index, child in pairs(Workspace:GetChildren()) do | |||
print("Index: ", index) | |||
print("Child: ", child) | |||
print(" | |||
print(" | |||
end | end | ||
</ | </syntaxhighlight>}} | ||
[[Category:Methods]] |
Latest revision as of 00:10, 18 April 2023
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