Problems with player input and animations

When the player holds RMB, it plays the charging and holding part of the animation.
When the player releases the RMB, it plays the releasing animations.
https://gyazo.com/623bc691d74bf33846db4f7e7a94c24c

However, if the player only clicks the RMB, the animation gets stuck, even though the release animation is still played.
https://gyazo.com/2156634b38d5586455a429787322abcd

It would probably help to have code. What is probably happen is your holding animation is looped, then your code never ends it, so it plays the release animation but is still playing the holding animation.

I had thought that as well, but I don’t see why this might happen if I’m already checking and removing the looping animation afterwards.
However, it doesn’t seem to work when clicking the mouse button.

function module:ToolHeld(input)
	if not self.CanFire then return end
	self.CanFire = false

	Animate(Animation, false)
	
	Animate(Animation, true)
end


function module:ToolReleased(input)
	if self.CanFire then return end
	
	Animate(Animation, false)	
	
	self.CanFire = true
end


function Animate(animationID, looped, name)
	
	local animation = Instance.new("Animation")
	animation.AnimationId = animationID
	
	if name then
		-- Only name idle animations
		animation.Name = name
	end
	if looped then
		if animation.Name ~= "Equip" then
			animation.Name = "looped"
		end
	end
	
	local animator = self.ViewModel.Humanoid:FindFirstChildOfClass("Animator")
	local AnimationTrack = animator:LoadAnimation(animation)
	
	-- Stop the looping animation
	for _, anim in ipairs(animator:GetPlayingAnimationTracks()) do
		if anim.Name == "looped" and anim.Name ~= "Equip" then
			anim:Stop()
		end
	end
	
	AnimationTrack.Looped = looped
	AnimationTrack:Play(0)
	
	AnimationTrack.Stopped:Wait()
end

Just a heads up, AnimationTrack.Looped doesn’t replicate:

Basically means it can’t be used.


I can’t see the problem with the code above, maybe another dev has some insight.

After putting the code stopping looping animations into its own function, it works partially. Clicking now results in the looping animation being ended.
However, the releasing animation still isn’t being played properly.
https://gyazo.com/04ad186ceaf8a46659950eceae290cda

You might want to just have the default hand pose be it’s own animation, kind of like an idle animation, then have the punch wind up be another animation with a higher priority, so then you only need to control the punch wind up animation and can use fade time to interpolate between the two poses.

This works, however, I want to be able to add a cooldown to the debounce before the player is able to swing again.
This doesn’t work when the player spams the mouse button.