What's the difference?

HI DEVS,

what’s the difference between :FindFirstChildWhichIsA() and :FindFirstChildOfClass()?
I didn’t quite understand on how Roblox explained it

2 Likes

I learned this a few minutes ago, I’m pretty sure FindFIrstChildWhichIsA works for these:

print(part:IsA("Part")) --> true
print(part:IsA("BasePart")) --> true
print(part:IsA("Instance")) --> true

all work for a part.

FindFirstChildOfClass won’t have BasePart work for part, only part.

Example, you use FindFirstChildWhichIsA("BasePart") to find children that are parts, meshparts, etc.

You use FindFirstChildOfClass("Part") to find a part.

1 Like

whats the difference between a basepart and a part?

A basePart includes part, meshPart, unionOperation, etc.

so part is more specific???

Yes, parts are most specific, a part is a basePart.

1 Like

For the developer hub documentation

1 Like

so :FindFirstchildOfClass() is just more specific then :FindFirstchildWhichIsA()?

FindFirstChildOfClass returns child with the exactly specified class.

FindFirstChildWhichIsA returns child with specified class or child that inherits (Share methods) from the specified class.

For example FindFirstChildWhichIsA("Instance") will return first child of any class because all Instances inherit from Instance.

2 Likes

Yeah, OfClass literally checks if the ClassName is the same. WhichIsA checks :IsA(), which checks for inheritance. For example, Parts, UnionOperations, and WedgeParts all inherit from BasePart, and SpawnLocation inherits from Parts, meaning it both IsA BasePart and IsA Part. You can see the hierarchy tree on the sidebar of the devhub.

3 Likes