FindFirstChild (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Mr Doom Bringer
No edit summary
>Mr Doom Bringer
No edit summary
Line 6: Line 6:
|object              = Global
|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>

Revision as of 05:38, 22 August 2007

FindFirstChild( 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.


Example


function OnTouched(hit)
 brick = hit.Parent:FindFirstChild("Torso")
 if (brick ~= nil) then
  brick.BrickColor = BrickColor.new(1)
 end
end

script.Parent.Touched:connect(OnTouched)