PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
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.