FindFirstChild (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Anaminus
No edit summary
>ArceusInator
redirect
Line 1: Line 1:
{|
#REDIRECT [[FindFirstChild (Method)]]
|<onlyinclude>{{Function|
name                  = FindFirstChild
|arguments            = [[String]] '''Name'''[, [[Bool]] '''recursive''']
|returns              = [[Instance]] ''child''
|description          = Returns the first child found with a name of '''Name'''. Returns ''nil'' if no such child exists.
|object              = [[Instance]]
}}</onlyinclude>
|}
 
==Description==
{{Example|
<pre>
local child = game.Workspace:FindFirstChild("Brick")
if child ~= nil then
    child:Remove()
end
</pre>
}}
 
'''recursive''' is an optional argument that, when true, will cause FindFirstChild to check through the object's child, it's children's children, and so on.
{{Example|
'''Structure:'''
Workspace <!--this needs a better representation-->
    Model
        Part   
<pre>
local part = game.Workspace:FindFirstChild("Part")      -- returns nil
local part = game.Workspace:FindFirstChild("Part",true)  -- returns Part
</pre>
}}
 
==See Also==
[[Instance Hierarchy]]

Revision as of 16:38, 11 January 2011