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

How to reference a player's humanoid?

Ahoy human beings,

I am still kind of confused on how to get a player's humanoid without a touch event.

If you don't understand what I am talking about, please feel free to ask questions.

Thanks everyone!

9 comments

0

ok I don't understand

0

So what I'm talking about is, how to reference a player's humanoid. For example, if you would make a normal veriable, you would say game.Workspace.Part or whatever, but it doesn't work the same way with a player's humanoid.

0

ok then use Player.Character or you can use for i,v in pairs(game.Players:GetPlayers()) do to get all of players

0

it completely depends on what you're doing.

0

When I try it out, the output keeps printing attempt to index nil with 'Character'

0

You cannot use a ServerScript and LocalPlayer in conjunction.

1 answer

✓ Accepted answer

I will show you how to reference it in a local script, and in a server script:

Server Script

game.Players.PlayerAdded:Connect(function(player) -- This gets the player
player.CharacterAdded:Connect(function(character) -- We already have the player, so this detects when the player's character is added into the game
-- The character is a child inside of the player
local humanoid = character.Humanoid
end)
end)

Local Script

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid

If I helped please accept this answer!

3 comments

0

Thanks for the local script one, but I don't understand the serverscript one.

0

Oh nevermind I get it now. Thanks!

0

Sorry I made a mistake, it should be fixed now, if you need any more help please ask! :)

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