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

FindFirstAncestorWhichIsA

Returns the first ancestor of the Instance for whom Instance/IsA returns true for the given className.

This function works upwards, meaning it starts at the Instance’s immediate Instance/Parent and works up towards the DataModel. If no matching ancestor is found, it returns nil.

Unlike Instance/FindFirstAncestorOfClass, 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 ancestor, regardless of if it is a WedgePart, MeshPart or Part.

local part = object:FindFirstAncestorWhichIsA("BasePart")

See also, Instance/FindFirstAncestor.

Parameters

Name Type Default Description

The Instance/ClassName to be looked for.

Returns

Return Type Summary

The Instance found.