PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

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 Instance/ClassName to be searched for.

false

Whether or not the search should be conducted recursively.

Returns

Return Type Summary

The Instance found.