FindFirstChild (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>XLEGOx
No edit summary
>ArceusInator
redirect
 
(32 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Function|
#REDIRECT [[FindFirstChild (Method)]]
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
|}}
 
 
==Example==
<pre>
 
while true do  --Starts up a While loop
  found = game.Workspace:FindFirstChild("Brick") --This looks in the Workspace for anything named "Brick", and sets the variable "found" to whatever object it finds.
 
  if brick ~= nil then  -- This makes sure that it actually found something. If the variable is nothing, then it ends.
 
    brick.Name = "blah"  --Sets the object's name to "blah"
 
  end  --End the If loop
 
end  --End the While loop
 
</pre>
 
==Recursive==
 
Recursive sets whether the function should look inside of objects in the calling object, as well as the calling object.
 
For example, if there is a part in workspace called "Part" and you use:
<pre>
game:FindFirstChild("Part", true)
</pre>
It will find the part.

Latest revision as of 16:38, 11 January 2011