I made this script for animations everything works fine, the only problem is the playing animation. If the playing animation is not done playing and the player unequips the tool, the equip animation stays and breaks until you pull the tool out to fix it.
Script For Equip, animationtrack1 is the equip, animationtrack 2 is the idle:
--On Equip--
Tool.Equipped:Connect(function()
local Character = Tool.Parent
local Humanoid = Character.Humanoid
ToolEquipSound.Playing = true
local AnimationTrack = Humanoid:LoadAnimation(EquipAnimation)
AnimationTrack:Play()
wait(.9)
local AnimationTrack2 = Humanoid:LoadAnimation(IdleAnimation)
AnimationTrack2:Play()
Tool.Unequipped:Connect(function()
if AnimationTrack2 then
AnimationTrack2:Stop()
end
end)
end)
How do I fix this so when the player unequips it stops playing and returns to normal?