FindFirstChild (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Travisdep
>ArceusInator
redirect
 
(43 intermediate revisions by 8 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>
 
function OnTouched(hit)
brick = hit.Parent:FindFirstChild("Torso")
if (brick ~= nil) then
  brick.BrickColor = BrickColor.new(1)
end
end
 
script.Parent.Touched:connect(OnTouched)
 
</pre>
 
==It can also be used to find objects with spaces==
<pre>
 
function OnTouched(hit)
brick = hit.Parent:FindFirstChild("Left Leg")
if (brick ~= nil) then
  brick.BrickColor = BrickColor.new(1)
end
end
 
script.Parent.Touched:connect(OnTouched)
 
</pre>

Latest revision as of 16:38, 11 January 2011