LocalScript can't find Humanoid

Probably the stupidest and most common error ever, but:

“Attempt to index nil with ‘Humanoid’”

Script path = StarterPlayer => StarterPlayerScripts => LocalScript

local Camera = workspace.CurrentCamera
local Players = game:GetService("Players") 
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character.Humanoid --errorline

Using any FindFirstChild or WaitForChild didn’t work.

Try

local Camera = workspace.CurrentCamera
local Players = game:GetService("Players") 
local Player = Players.LocalPlayer
local Character = Player.Character or Player.Character:Wait()
local Humanoid = Character.Humanoid

The reason it doesn’t find the Humanoid is that the Character hasn’t loaded, so you need to wait for it to load.

2 Likes

Try to use this script, but on StarterPlayer > StarterCharacterScripts:

local Camera = workspace.CurrentCamera
local Players = game:GetService("Players") 
local Player = Players.LocalPlayer
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
5 Likes

Player.Character is not an event, maybe you were trying to talk about Player.CharacterAdded, but anyways this event is now deprecated.

I’m using a “LocalScript” as stated in the title of this thread lol

1 Like