How do I change an animation's priority from a script?

I’m creating a function that will play animations from just their id, here’s the code I have so far.

(Yes I know I’m using the deprecated humanoid:LoadAnimation() function, but doing it through the animator seemed like extra work)

local function Animate(id, callback)
	local animation = Instance.new("Animation")
	animation.AnimationId = baseURL:format(id)
	
	local track = humanoid:LoadAnimation(animation)
	track.AnimationPriority = Enum.AnimationPriority.Action
	
	track:Play()
	
	track.Stopped:Connect(function()
		coroutine.wrap(callback)()
		animation:Destroy()
	end)
end

Here’s the error im getting:

17:07:29.678  AnimationPriority is not a valid member of AnimationTrack "Animation"
18 Likes

Use Priority:

track.Priority= Enum.AnimationPriority.Action
25 Likes

Works now, thank you! :smiley:

Must’ve passed by it while looking at the properties for the animation track

LoadAnimation() is deprecated?

3 Likes