Running Animation Playing Over Every Animation

So I have finally finished my movement system for my game but found that my running animation is overriding everything else when it’s being played. I also put my code here just incase the code is messing something up. Inform me if you figured out what’s wrong because it is really messing it up. Like if Im holding shift and price spacebar, it doesn’t play the jumping animation. It wont play any animation and I want those to play instead of the running.

local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character

UIS.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		Character.Humanoid.WalkSpeed = 35  --run speed
		local Anim = Instance.new('Animation')
		Anim.AnimationId = 'rbxassetid://15564406328'
		PlayAnim = Character.Humanoid:LoadAnimation(Anim)
		PlayAnim:Play()
	end
end)

UIS.InputEnded:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		Character.Humanoid.WalkSpeed = 16  --default walk speed
		PlayAnim:Stop()
	end
end)

You can change the priority of the AnimationTrack, which is “PlayAnim” in your scenario, by changing the Priority property on it:

PlayAnim.Priority = Enum.AnimationPriority.Action

You can test each priority to see which one suits your needs, most people override with Action.


References:

https://create.roblox.com/docs/reference/engine/enums/AnimationPriority

https://create.roblox.com/docs/reference/engine/classes/AnimationTrack#Priority

I tried this but turns out I did it wrong. Thanks for helping me anyways. I thought I was going the wrong direction with priority but you set me back on track. Thanks!

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