FindFirstChild (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>GoldenUrg
Added link
>ArceusInator
redirect
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{|
#REDIRECT [[FindFirstChild (Method)]]
|<onlyinclude>{{Function|
name                  = FindFirstChild
|arguments            = [[String]] '''Name'''[, [[Bool]] '''recursive''']
|returns              = [[Instance]] ''found object''
|description          = Returns the first child found with a name of '''Name'''. Returns ''nil'' if no such child exists.
|object              = Global
}}</onlyinclude>
|}
 
==Example==
<pre>
--This looks in the Workspace for anything named "Brick",
-- and sets the variable "found" to whatever object it finds.
-- if nothing is found, then found is nil.
found = Workspace:FindFirstChild("Brick") 
 
if found ~= nil then  -- This makes sure that it actually found something.
  found.Name = "blah"  --Sets the object's name to "blah"
end
</pre>
 
==Recursive==
The '''recursive''' argument is optional.
If given, '''Recursive''' sets whether the function should look inside of objects in the calling object, as well as the calling object. If not given, the default is false.
 
For example, if there is a part in Workspace called "Part" and you use:
part = Game:FindFirstChild("Part", true)
It will find the part.
part = Game:FindFirstChild("Part", false)
OR
part = Game:FindFirstChild("Part")
Will not.
 
==See Also==
[[Instance Hierarchy]]

Latest revision as of 16:38, 11 January 2011