Add recursive parameter to FindFirstChildOfClass

As a Roblox developer, it requires extra work to make FindFirstChildOfClass work recursively, similar to FindFirstChild. It would only make sense to make the same compatibility to the newer method, FindFirstChildOfClass.

The usage expected would be exactly the same of the second parameter of FindFirstChild, where if true, it will search recursively throughout the objects.

Might I add that it is the only of its kind that does not have the recursive parameter.

image

13 Likes

Would help better if you provided a use case.

1 Like

Wait, wouldn’t FindFirstChildWhichIsA be the recursive version of FindFirstChildOfClass, since they both take className as the first arg. If they made FindFirstChildOfClass have recursive then those 2 would pretty much do the same thing? :thinking:

WhichIsA and OfClass are NOT the same thing. OfClass checks class names, WhichIsA calls :IsA.

1 Like

Well I know that. But they both take ClassName as the first argument. Thus, FindFirstChildWhichIsA can return what FindFirstChildOfClass can return, but the “WhichIsA” version is recursive so we could use that instead of the “OfClass” version.

print(workspace:FindFirstChildWhichIsA(“Part”)) → Baseplate
print(workspace:FindFirstChildOfClass(“Part”)) → Baseplate

Depends on the use case. Sometimes you can’t use WhichIsA, such as capturing Decals instead of Textures and Parts instead of Seats/SpawnLocations. They’re far and few between but they exist.

1 Like

MeshParts, Parts, Trusses, Wedges (I believe) and other objects are members of the BasePart class. If you want to easily check for different types of parts you can do “:IsA(“BasePart”)” instead of “:IsA(“Part”) or :IsA(“MeshPart”) or :IsA(“TrussPart”)…” etc

This is useful for other stuff too like GUI objects (GuiBase)

1 Like

Yes I was aware, thanks :smile:

I’ve used :IsA(“BasePart”) plenty of times when using recursive before attempting to use a property only baseparts have such as brickcolor and position.

Perhaps they should add recursive to FindFirstChildOfClass just so all 3 of them have it. Keeps things consistent and you never know when someone might prefer “OfClass” over “WhichIsA”.

2 Likes

Bumping because this is still needed. Why is FindFirstChildOfClass the only form of FindFirstChild without a recursive parameter? It’s baffling.

:IsA plainly isn’t functionally equivalent to checking the ClassName. If I’m searching for an instance that matches a specific class, I don’t want my efforts to be thwarted by another instance that so happens to inherit from the class I’m actually looking for. I also can’t always foresee how inheritance will change in the future. When I’m working with my own systems, I know exactly what classes comprise its components. Strictly evaluating by ClassName in these cases, will always be more reliable than settling for :IsA. But that would be humoring the notion that these approaches are functionally comparable; when in fact again, “WhichIsA” is simply not a substitute for “OfClass”.

1 Like