FindFirstChild (Function): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>GoldenUrg Added link |
>Anaminus No edit summary |
||
Line 3: | Line 3: | ||
name = FindFirstChild | name = FindFirstChild | ||
|arguments = [[String]] '''Name'''[, [[Bool]] '''recursive'''] | |arguments = [[String]] '''Name'''[, [[Bool]] '''recursive'''] | ||
|returns = [[Instance]] '' | |returns = [[Instance]] ''child'' | ||
|description = Returns the first child found with a name of '''Name'''. Returns ''nil'' if no such child exists. | |description = Returns the first child found with a name of '''Name'''. Returns ''nil'' if no such child exists. | ||
|object = | |object = [[Instance]] | ||
}}</onlyinclude> | }}</onlyinclude> | ||
|} | |} | ||
== | ==Description== | ||
{{Example| | |||
<pre> | <pre> | ||
local child = game.Workspace:FindFirstChild("Brick") | |||
if child ~= nil then | |||
child:Remove() | |||
if | |||
end | end | ||
</pre> | </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== | ==See Also== | ||
[[Instance Hierarchy]] | [[Instance Hierarchy]] |
Revision as of 22:56, 24 October 2010
|
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