Why isn't my equip animation working?

I have the equip animation set to action and i’ve imported it into the sword but when equipped it skips the animation and instead goes to the idle animation.

Do something like this:

local Tool = script.Parent
local EquipAnimation = script.Parent.Animation

Tool.Equipped:Connect(function(plr)
   local character = plr.Character
   local animationtrack = character.Humanoid:LoadAnimation(EquipAnimation)
   animationtrack.Priority = Enum.AnimationPriority.Action
   animationtrack:Play()
end)

Tool.Unequipped:Connect(function()
   animationtrack:Stop()
end)

Make sure you have your idle animation set with the idle priority and your equip animation set with an action priority

Did that, equip still doesn’t work and now idle doesn’t use both arms.

Made a few mistakes, edited. Try now.

Animations only work in a localscript.

Make sure it is also looped.

Also Humanoid:LoadAnimation() is deprecated.

Make sure priority is already set to the highest or what you want in the animation editor (I recommend personally to use Moon animator)

local PLayer = game:GetService("Players").LocalPlayer
local Tool = script.Parent
local EquipAnimation = script.Parent.Animation
local Character = Player.Character
local AnimationTrack = Character.Humanoid.Animator:LoadAnimation(EquipAnimation)

Tool.Equipped:Connect(function()
    AnimationTrack:Play()
end)

Tool.Unequipped:Connect(function()
    AnimationTrack:Stop()
end)