GetChildren (Function): Difference between revisions
From Goodblox Wiki
Jump to navigationJump to search
Pizzaboxer (talk | contribs) (Created page with "<onlyinclude>{{Function| name = GetChildren |arguments = |returns = Table ''children'' |description = Returns a read-onl...") |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{CatUp|Functions}} | |||
<onlyinclude>{{Function| | <onlyinclude>{{Function| | ||
name = GetChildren | name = GetChildren | ||
|arguments = | |arguments = | ||
|returns = [[Table]] ''children'' | |returns = [[Tables|Table]] ''children'' | ||
|description = Returns a read-only table of this Object's children | |description = Returns a read-only table of this Object's children | ||
|object = Global | |object = Global | ||
Line 9: | Line 10: | ||
==Example== | ==Example== | ||
(Simple example) | (Simple example) | ||
<pre> | <pre> | ||
local children = workspace:GetChildren() | |||
local children = | |||
for c = 1, #children do | for c = 1, #children do | ||
print(children[c].Name) | |||
end | end | ||
</pre> | </pre> | ||
(More efficient example) | (More efficient example) | ||
<pre> | <pre> | ||
local children = | local children = workspace:GetChildren() | ||
for i, | for i, item in pairs(children) do | ||
--"item" is the object, "i" is the index of the table it is at | |||
print("index: "..i) | |||
print("Object: "..item) | |||
end | end | ||
</pre> | </pre> | ||
[[Category:Functions]] | [[Category:Functions]] |
Latest revision as of 21:24, 25 September 2021
Function | |
---|---|
Syntax | GetChildren( ) |
Returns | Table children |
Description: | Returns a read-only table of this Object's children |
In Object: | Global |
Example
(Simple example)
local children = workspace:GetChildren() for c = 1, #children do print(children[c].Name) end
(More efficient example)
local children = workspace:GetChildren() for i, item in pairs(children) do --"item" is the object, "i" is the index of the table it is at print("index: "..i) print("Object: "..item) end