FindFirstChildWhichIsA
Returns the first child of the Instance for whom Instance/IsA returns true for the given className.
If no matching child is found, this function returns nil. If the optional recursive argument is true, this function searches all descendants rather than only the immediate children of the Instance.
Unlike Instance/FindFirstChildOfClass, this function uses Instance/IsA which respects class inheritance. For example:
print(part:IsA("Part")) --> true
print(part:IsA("BasePart")) --> true
print(part:IsA("Instance")) --> true
Therefore, the following code sample will return the first BasePart child, regardless of if it is a WedgePart, MeshPart or Part.
local part = object:FindFirstChildWhichIsA("BasePart")
Developers looking for a child by name, should use Instance/FindFirstChild instead.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
|
|
The |
||
|
false
|
Whether or not the search should be conducted recursively. |
Returns
| Return Type | Summary |
|---|---|
|
The |