Animation not playing second time

Hello, i have script that make walk animation play when gun equips and i’m walking. Bur when i walk and then unequip gun, then again equip it. Animation simply dont play. No errors, even print is saying that animation is playing currently.

script.Parent:WaitForChild("Equiped").Event:Connect(function(arms) -- arms is a viewmodel, that i get by bindable event
	print("Event")
	player.Character.Humanoid.Changed:Connect(function()
		if arms then
			if not runninganim then runninganim = arms.Humanoid:LoadAnimation(arms.Animations.WalkAnim) end
			if not fastrunninganim then fastrunninganim = arms.Humanoid:LoadAnimation(arms.Animations.RunAnim) end
			runninganim:AdjustSpeed(player.Character.Humanoid.WalkSpeed * 0.05)
			if player.Character.Humanoid.MoveDirection.Magnitude > 0 and player.Character.Humanoid.WalkSpeed <= 12 then
				if not runninganim.IsPlaying then
					runninganim:Play(0.15) -- not playing second time when i walking
					running:Stop(0.25)
					fastrunninganim:Stop(0.25)
				end
			elseif player.Character.Humanoid.MoveDirection.Magnitude <= 0 then
				runninganim:Stop(0.15)
				fastrunninganim:Stop(0.25) -- not playing second time when i running
				running:Stop(0.25)
			elseif player.Character.Humanoid.WalkSpeed > 12 and player.Character.Humanoid.MoveDirection.Magnitude > 0 then
				if not fastrunninganim.IsPlaying then
					fastrunninganim:Play(0.25) -- not playing second time when i running
					running:Play(0.25) -- not playing second time when i running (player's character animation)
					runninganim:Stop(0.15)
				end
			end
		end
	end)
end)

What priority action is your walk and gun animation is set to ? It could be that the walking animation is overriding your gun animation.

I mean my walking animations is not working. I even tried to disable gun idle animation. And walking animation is still not playing, problem is not in priority

Sorry, but I couldn’t understand your problem. What are you trying to achieve? Can you show us a video that visualizes the problem/bug?

I’m just fixed this bug. I added a new BindableEvent called Unequip that calls when gun is unequiped, and in this script i added this:

script.Parent:WaitForChild("Unequiped").Event:Connect(function(arms) 
	runninganim = nil
	fastrunninganim = nil
end)

I’ll try to explain the problem anyway. I have a walking animation that only worked once, that is, when I equipped the weapon once. When I unequip my weapon and then equip it back, the walking animations were no longer working. In general, the problem was in the animations themselves, they were already loaded by LoadAnimation() and for some reason they did not play the second time. So I had to change them as nil every time I put unequip gun…

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.