FindFirstChild (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Anaminus
No edit summary
>Anaminus
No edit summary
(No difference)

Revision as of 22:56, 24 October 2010

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