Attempt to index nil with 'LoadAnimation'

I’m getting this error but I dont know why, Here is the bit of code causing it

local hum = game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name):FindFirstChild("Humanoid")
local minerground = hum:LoadAnimation(game.ReplicatedStorage.MinerAnimations.MineGround)

This is in a local script.

It could be because the script loads before the player. I would recommend making sure the character is loaded in first.

You could do

local Player = game.Players.LocalPlayer
local character = Player.Character
if not character or not character.Parent then
	character = Player.CharacterAdded:wait()
end
local hum = character.Humanoid
local minerground = hum:LoadAnimation(game.ReplicatedStorage.MinerAnimations.MineGround)
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitFirstChild("Humanoid")
local minerground = hum:LoadAnimation(game.ReplicatedStorage.MinerAnimations.MineGround)

I would recommend using the Animator instead of the Humanoid

You have the local player instance from game.Players.LocalPlayer, to get its character you just need to index its Character property.

local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:Wait()
local hum = char:FindFirstChildOfClass("Humanoid")
local minerground = hum:LoadAnimation(game.ReplicatedStorage.MinerAnimations.MineGround)

You MUST also own the animation to gain access to the animation itself.