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

What is FindFirstChildOfClass and how do you use it?

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

2 answers

✓ Accepted answer

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!

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!

1 comment

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.)

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