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

How to reference a player's humanoid?

Asked by
LazokkYT 117
4 years ago

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!

0
ok I don't understand Mr_m12Ck53 105 — 4y
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. LazokkYT 117 — 4y
0
ok then use Player.Character or you can use for i,v in pairs(game.Players:GetPlayers()) do to get all of players Mr_m12Ck53 105 — 4y
0
it completely depends on what you're doing. Mayk728 855 — 4y
View all comments (5 more)
0
When I try it out, the output keeps printing attempt to index nil with 'Character' LazokkYT 117 — 4y
0
You cannot use a ServerScript and LocalPlayer in conjunction. Ziffixture 6913 — 4y

1 answer

Log in to vote
1
Answered by
zomspi 541 Moderation Voter
4 years ago
Edited 4 years ago

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!

0
Thanks for the local script one, but I don't understand the serverscript one. LazokkYT 117 — 4y
0
Oh nevermind I get it now. Thanks! LazokkYT 117 — 4y
0
Sorry I made a mistake, it should be fixed now, if you need any more help please ask! :) zomspi 541 — 4y
Ad

Answer this question