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

How do you get the humanoid from a player? This is all the code I have.

game.Players.PlayerAdded:Connect(function(plr)



end)

1 comment

0

I tried local char = plr.Character\nlocal hum = char.Humanoid but it didn't work.

2 answers

✓ Accepted answer
function onCharacterAdded(Character)
	local Humanoid = Character:WaitForChild("Humanoid")
end

function onPlayerAdded(Player)
	Player.CharacterAdded:Connect(onCharacterAdded)
end

game:GetService("Players").PlayerAdded:Connect(onPlayerAdded)

You can also do

game:GetService("Players").PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character) 
		local Humanoid = Character:WaitForChild("Humanoid")
	end)
end)

In both examples what we're doing is that we have an event in which every time its fired we get the Player in the parameters in the PlayerAdded event. Afterwards we use the CharacterAdded event with the Player which fires and we get the Character which is in the parameters in the event. We then make a variable which waits for the humanoid to load in and then changes said variable's value into the humanoid.

4 comments

0

Thank you, this helped a lot.

0

No problem!

0

ok this isnt rlly getting the humanoid from the player but u did what he wanted

0

actually it is but okay

if you are looking to get a player from the character after the player has touched something then you do

local player = game.Players:GetPlayerFromCharacter(from the place you have character in here)

1 comment

0

I was hoping for a way to get the character my way.

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