How to get all ancestors of an instance

uhh still not good.
image

1 Like

Small bump but you can do something like:

for _, directory in pairs(addressStrings) do
print(directory)
end

Just prints each thing inside the “addressStrings” table

1 Like
Obj:IsAncestorOf(AncestorPart)
1 Like

That doesn’t answer the OP’s question; it just returns a boolean on whether or not an Instance is an Ancestor of another Instance. The OP is asking how to fetch all of the Ancestors of an Instance

1 Like

You can use Obj:GetFullName() which returns the EXACT path of something. Then based on that, you can run a for loop to find if it is a descendant of something.

5 Likes

–When current == game, stop the code

I believe your function is meant to look like this
function getPath(instance)
local path = instance.Name
local current = instance.Parent
while current do
path = current.Name … “.” … path
current = current.Parent
end
return path
end

2 Likes

Correction: ipairs. I’ll try this whenever i can.

Hmm. I’m gonna look more into it. Never knew this method existed.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.