Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What are the classes of an object and part?

Asked by 4 years ago

I see people typing "child" , "parent" , "descendant" , "ancestors" but what do they mean like I only know child and parent but what is descendant and ancestor? What are the functions?

1 answer

Log in to vote
1
Answered by 4 years ago

What do descendants and ancestors mean in the real world?

A descendant is a direct or indirect child. A good example is you are their grandparents. You are not directly their children but you're their descendant. But you're still your parents (mom and dad) descendants.

And they are your ancestors. The only functions I know of is GetChildren, GetDescendats, IsAncestorOf, IsDescendantOf.

For some reason roblox doesn't provide a GetAncestors function.

Eh just for fun I wrote this.

local function get_ancestors(instance)
    local instance_parent = instance.Parent
    local ancestors = { instance_parent }

    while instance_parent do
        instance_parent = instance_parent.Parent
        table.insert(ancestors, instance_parent)
    end
    return ancestors
end
Ad

Answer this question