Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How does :FindFirstAncestor() find the first ancestor?

1 answer

I don't know but this is my guess. This is hardly tested and is very messy, and likely won't work but this is my basic idea.

local function findAncestor(object,name)
	local Parents = {}
	local Index = object
	local Done = false
	repeat
		table.insert(Parents,Index.Parent)
		
			
			print(Index)
		if Index.Parent.Name == name then
			Done = true
		elseif Index == game then
			Done = true
		end

		Index = Index.Parent
	until Done == true
	return Index
end

findAncestor(PartExample, "NameExample") -- Example

This discussion is preserved as it was. New answers, comments, and votes are closed.