LoadAnimation requires the Humanoid object

SO i have a tool with animations, everytime the humanoid dies the tool prints that error

-- Variables 
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AnimationModule = ReplicatedStorage:WaitForChild("AnimationModule")
local UserInputService = game:GetService("UserInputService")
-- Player Itself
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
repeat wait(1) until Character

local Humanoid = Character:WaitForChild("Humanoid")

-- Tool
local Tool = Player.Backpack:WaitForChild("Sword")
local Blocking = Tool:WaitForChild("Blocking")
local Event = Tool.Event
-- Animations
local IdleAnimation = Humanoid:LoadAnimation(Tool.IdleAnimation)
IdleAnimation.Priority = Enum.AnimationPriority.Movement
local BlockAnimation = Humanoid:LoadAnimation(Tool.BLOCK)

local SwingAnimation = Humanoid:LoadAnimation(Tool.ActionAnimations.Swing)
local SpinAnimation = Humanoid:LoadAnimation(Tool.ActionAnimations.Spin)

you probably get that error because your script runs even after the humanoid died, before running a script that needs animation check if humanoid is alive and if not then don’t run the script
If humanoid.Health <= 0 then

So how would i do it xd? :thinking:

What… i just explained.
Ok so i see you have a blocking animation there, so lets pretend that every time you press RBM, blocking animation plays. So basically before that animation plays you just check if humanoid is alive, if not then return so the script won’t run

im asking how would i do it because the error comes from this line

Try putting the code below after you define Humanoid
until Humanoid
It basically can’t find the humanoid because the humanoid is not defined yet when the script runs. If not then i don’t know what’s your problem. At least provide a screenshot of the error


check this one