PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

FindFirstAncestorOfClass

Returns the first ancestor of the Instance whose Instance/ClassName is equal to 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.

A common use of this function is finding the Model a BasePart belongs to. For example:

local model = part:FindFirstAncestorOfClass("Model")

This function is a variant of Instance/FindFirstAncestor which checks the Instance/ClassName property rather than Instance/Name. Instance/FindFirstAncestorWhichIsA also exists, using the Instance/IsA method instead to respect class inheritance.

Parameters

Name Type Default Description

The Instance/ClassName to be looked for.

Returns

Return Type Summary

The Instance found.