Tool doesn't want to load animation after reset/death, in starterpack

So I have troubles with that script. I’m sure that something is wrong in the header part of the script. I don’t know if the way to load animations is bad though.

Here’s the script ;
(Local script located in the tool by the way)

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local h = char:WaitForChild('Humanoid')

----- animations -----

local anim1 = h:LoadAnimation(script.Parent:WaitForChild("a1")) -- equip
local anim2 = h:LoadAnimation(script.Parent:WaitForChild("a2")) -- unequip
local anim3 = h:LoadAnimation(script.Parent:WaitForChild("a3")) -- drink
local anim5 = h:LoadAnimation(script.Parent:WaitForChild("a5")) -- idle

----------------------

------- sounds -------

local sound = script.Parent.Sound3 -- equip

----------------------

local tool = script.Parent


tool.Equipped:Connect(function()
	
	sound:Play()
	
	anim1:Play()
	wait(1.15)
	anim5:Play()
	
end)

tool.Activated:Connect(function()
	
		anim3:Play()

end)

tool.Unequipped:Connect(function()
	
	sound:Play()
	anim1:Stop()
	anim3:Stop()
	anim5:Stop()
	anim2:Play()
	wait(1.15)
	anim2:Stop()
	

end)

Works perfectly on first load, but when I die ;
image

Maybe on the player.CharacterAdded ?.. I don’t know, I’ve been already searching for hours. Maybe searching in the wrong direction, but I tried.

Thanks for helping !

The error itself is pretty self explanatory.
The Humanoid isn’t a descendant of game, so game can’t ‘read’ the animation’s contents

1 Like

So maybe more like

game:GetService(“Players”) ?

I still don’t get where to go with that…

Found the solution ;

local tool = script.Parent

tool.Equipped:Connect(function()

local chr = tool.Parent
local h=chr:FindFirstChild("Humanoid")

local an1 = tool:FindFirstChild("a1") -- equip
local an2 = tool:FindFirstChild("a2") -- unequip
local an3 = tool:FindFirstChild("a3") -- drink
local an5 = tool:FindFirstChild("a5") -- idle

anim1=h:LoadAnimation(an1)
anim2=h:LoadAnimation(an2)
anim3=h:LoadAnimation(an3)
anim5=h:LoadAnimation(an5)

local sound = script.Parent.Sound3

sound:Play()

anim1:Play()
wait(1.15)
anim5:Play()

end)

tool.Activated:Connect(function()

anim3:Play()

end)

tool.Unequipped:Connect(function()

sound:Play()
anim1:Stop()
anim3:Stop()
anim5:Stop()
anim2:Play()
wait(1.15)
anim2:Stop()

end)