Not detecting Humanoid

Hi, I’m working on a tool script, but the script does not detect the Players Humanoid. I need help for clarification on how to improve. Included are the script, and error message.

----Variables

--Player/Humanoid/Animation/Tool

local Player = game.Players.LocalPlayer
local Humanoid = Player.Character:WaitForChild("Humanoid")

local Anim = Humanoid.Animator:LoadAnimation(script:WaitForChild("Animation"))
local Tool = script.Parent
1 Like

The script is running before the character loads in (so it tells you that Player.Character is nil), you need to wait for the character first:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait() -- waits for character to load if it doesn't exist yet
local Humanoid = Character:WaitForChild("Humanoid")
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.