Animation Priority Issue

So I’ve been trying to set up an animation that plays when you step over a part. I am 100% sure that the code itself works, but this leads me to my issue
I have the animation as a member of the script. The problem is that any action done by the player such as jumping or even walking stops the animation that I’m trying to have the player do.

Here’s my code:

local Axe = script.Parent.BasicAxe
script.Parent.Touched:connect(function(hit)
	local Parent = hit.Parent
	if game.Players:GetPlayerFromCharacter(Parent) then
		local Anim = script:WaitForChild("Animation")
		local Humanoid = Parent.Humanoid
		local DoAnim = Humanoid:LoadAnimation(Anim)
		DoAnim.Priority = Enum.AnimationPriority.Action
		DoAnim.Looped = true
		DoAnim:Play()
end
end)

Here’s what happens:
https://gyazo.com/f8cf2699c8241386174a0c58d4bcd7c6
(You can slightly see the animation play at the beginning, but when I stop walking, it stops)

Any ideas to why the Action Priority is being overridden by the default animations?

You could connect a function to the .Stopped event; otherwise, you could try disabling the “Animate” script in the character. That works in some cases, but it can cause issues later on.

Maybe the Animation priority is set to core, Change it to Action like this and it will stop the issue from occuring.

image

1 Like

But his script changes the AnimationTrack’s priority to action.
DoAnim.Priority = Enum.AnimationPriority.Action

2 Likes

I ended up doing what Zombiefin suggested and change the priority through the Animation Editor. That worked. Strange why it didn’t work in the script though.

2 Likes

I believe this is due to how roblox leads animations, I dont think you can really change the animation that much once it is loaded in. Also, the animation edtior might override the physical property.

Dont forget to mark a post as a solution if it solved the problem.

2 Likes