FindFirstChild (Function)

From Legacy Roblox Wiki
Revision as of 22:56, 24 October 2010 by >Anaminus
Jump to navigationJump to search
FindFirstChild( 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.

Description

Example
local child = game.Workspace:FindFirstChild("Brick")  
if child ~= nil then
    child:Remove()
end


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 
    Model
        Part    
local part = game.Workspace:FindFirstChild("Part")       -- returns nil
local part = game.Workspace:FindFirstChild("Part",true)  -- returns Part


See Also

Instance Hierarchy