Animation not loading/playing when holding a tool

I wanted to create a sword for a personal project. The intent was to have the sword swing when the player clicks. Lately I’ve been running into issues with animations. I created a swinging animation, but when the code tries to play the animation, the animation doesn’t play. I found a discussion page talking about a similar problem. The solutions proposed do not work however. In addition, after some testing, I discovered that the animation plays only if the tool is unequipped. Any fixes to this would be appreciated!

The code used to play the animation:


    function PlayAnimation(Animation)
    	wait()
    	local NewAnimation = Instance.new("Animation")
    	NewAnimation.AnimationId = Animation.AnimationId
    	
    	local AnimationTrack = Humanoid:LoadAnimation(NewAnimation)
    	
    	AnimationTrack:Play()
    end
4 Likes

Check the Animation Priority in the Animation Editor. Chances are, the default tolenone animation is overlapping yours. I recommend setting it to Idle or Action.

6 Likes

Try adding an On Click to let the animation know when to play (when the player clicks). Also check and make sure the animation is set to Action.