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

What are the classes of an object and part?

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

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

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