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

What is FindFirstChildOfClass and how do you use it?

Asked by 6 years ago
Edited 6 years ago

Does FindFirstChildOfClass() mean finding something that is in a class like how :IsA() does?

2 answers

Log in to vote
0
Answered by 6 years ago

Yes, but it acts a little differently. So, you could do

game.Workspace.hiimgoodpack:FindFirstChildOfClass('Humanoid')

to get the humanoid, even if the humanoid is renamed. :IsA needs the current object like

print(tostring(game.Workspace.hiimgoodpack:FindFirstChildOfClass('Humanoid'):IsA('Humanoid')))

:IsA checks if a item is a class name, and has some bonuses. Instead of writing a table of all the GUI objects, you could just do

print(tostring(ScreenGui:IsA('GuiObject')))

Hope this helps!

Ad
Log in to vote
0
Answered by 6 years ago

Yes it does. For example:

game.Players.PlayerAdded:Connect(function(Player) 
    player.CharacterAdded:Connect(function(Character)
        if Character:FindFirstChildOfClass("Humanoid") then --it's like IsA(), yes. 
            print("Found humanoid!")
        end
    end)
end)

Please accept my answer if this helped!

0
You might want to mention the difference between :FindFirstChildOfClass() and :FindFirstChildWhichIsA(). The first one matches the class exactly, the second one matches subclasses, too (similar to how :IsA() matches classes.) XAXA 1569 — 6y

Answer this question