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

How do you load in Humanoid In local scripts and scripts?

Hello I always had problems with Humanoid. something. But today I want to learn about correctally using Humanoid. I know what it can do but I don't know how do you it. This is what I do to set Humanoid to Humanoid

local players = game.Players.LocalPlayers
local Character = players:WaitForChild("Character")
local Humanoid = Character:WaitForChild("Humanoid")

But this doesn't work. How do you use and set up Humanoid in scripts? Thanks

This is the error code Humanoid is not a valid member of Model

1 answer

"LocalPlayers" is not a thing. It should be LocalPlayer.

local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait() --You don't actually have to do this but it's just in case the character is already loaded.
local Humanoid = Character:WaitForChild("Humanoid")

Edit:

In a ServerScript, you could do this to refer to the humanoid:

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	local Character = player.Character or player.CharacterAdded:Wait()
	local Humanoid = Character:WaitForChild("Humanoid")
end)

Don't forget to accept the answer if I helped!

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