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.

3 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")
7 Likes

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

1 Like

this didn’t work for me. when you do this code what it is accessing is this:

( Explorer )
○ Players
○ “some player”
• backpack
• PlayerScripts

no HUMANOID whatsoever. at this point I think the only way to access the player is to call a remote event to a server script that sees the workspace.

this is insane.

i tried this:

however, the PlayerAdded callback or event is not FIRING.