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

When do I use Humanoid and when do I use Player?

I just want to know, when do I use Humanoid and Player? To be more specific here are two lines of code:

local human = PartThatTouched.Parent:FindFirstChild("Humanoid")

and

local character = game.Players:GetPlayerFromCharacter(hit.Parent)

For example, I'd need to use character to change, let's say leaderstats since I can't use humanoid. Does that mean I can replace humanoid with character?

1 answer

✓ Accepted answer

character refers to the player (ie a child of game.Players), while human refers to the Humanoid within a player's character (which is a Model within the Workspace). Thus, if you do human.Parent, you're going to get the player's Character model (in the workspace -- not the character variable you have in your code), but if you do character.Parent, you're going to get game.Players.

If you look at the Roblox API, you can look up what you can do with a Humanoid versus what you can do with a Player. For example, the first entry in Player is "AccountAge". You could do print(character.AccountAge).

I am confused with what your final question is asking. Are you asking if you can replacing FindFirstChild("Humanoid") with FindFirstChild("Character")? If so, no. Are you asking if character and human are interchangeable? If so, no. You rightly point out that leaderstats are typically held as a child of the Player (which character refers to in your code).

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