Yuari
Documentation
Docs/Instances/FindFirstAncestor

FindFirstAncestor

Returns the first parent whose Name equals the query.

Syntax

inst:FindFirstAncestor(name: string) -> Instance?

Parameters

ParameterTypeDescription
namestringExact Name to match while walking up the parent chain.

Returns

TypeDescription
Instance?The closest matching ancestor, or nil.

Description

Walks up to 64 parent levels, starting with the direct parent.

Matching is by Name; use :FindFirstAncestorOfClass or :FindFirstAncestorWhichIsA for class checks.

Example

local part = Instance.new("Part", workspace.Model)
print(part:FindFirstAncestor("Model"))
print(part:FindFirstAncestor("Missing"))  -- nil

Notes

  • FindFirstAncestor(name) — Stops at the first match; use recursive searches if you need descendants.