DrProx
|
  |
| Joined: 18 Nov 2009 |
| Total Posts: 1138 |
|
|
| 08 Sep 2013 01:33 PM |
FindFirstChild has a SECOND PARAMETER!
It's a boolean value and when set to true it searches the item specified, and ALL ITS CHILDREN, and its CHILDREN'S CHILDREN, and so on.
By default this is set to false.
Note that it will only return the FIRST instance it finds, so you need to narrow it down where it won't find two or more. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2013 01:36 PM |
| I don't use second arg tho. |
|
|
| Report Abuse |
|
|
Absurdism
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 2568 |
|
|
| 08 Sep 2013 01:37 PM |
Yeah, it's pretty useful for recursive functions.
repeat Workspace:findFirstChild('BasePart', true):Destroy() until not Workspace:findFirstChild('BasePart', true) |
|
|
| Report Abuse |
|
|
DrProx
|
  |
| Joined: 18 Nov 2009 |
| Total Posts: 1138 |
|
|
| 08 Sep 2013 01:51 PM |
@Absurdism
That's always been how I use it. It even helps when you need to batch rename parts. :P
name = "Part1" repeat c,d = pcall(function() workspace:FindFirstChild(name).Name = "PartObject" end) until not c |
|
|
| Report Abuse |
|
|