|
|
(41 intermediate revisions by 7 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>
| |