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

What is FindFirstAncestor and FindFirstAncestorWhichIsA?

I tried to find more about this but didn't get much detail about these differences and why are they used for if you can help about it. It will be really appreciated.

1 answer

✓ Accepted answer

You have to know the difference between Child and Ancestor first. Basically, a child is under an object in the game hierarchy. But ancestor can be a child of a child of a child etc. So by using FindFirstAncestor, you will be checking if there is an object under the child of a child. So let's say you have a car in workspace and want to check if it has an object called "Wheel", and it looks like this: Car > Model > Wheel. If you used FindFirstChild, it wouldn't find, as it would look ONLY under "Car". And FindFirstAncestor would look under CAR and MODEL. So this could be used for FindFirstAncestorWhichIsA, wich is the same as IsA, wich instead of the Name it uses the ClassName, wich is the name of the object. Some sample codes:

if Car:FindFirstAncestorWhichIsA("Part") then -- will look in the Car hierarchy for an object wich is a Part
	print("Part found")
end

if Car:FindFirstAncestor("Wheel") then -- will look for an object called Wheel in the Car hierarchy
	print("Wheel found")
end

Hope I explained it well!

1 comment

0

Hey i really liked your explanation you explained really well i really appreciate your time for this.

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