Animation Priority in Editor overriding script

I just came across an issue when trying to run one of my animations. It seems that whatever animation priority I initially set on the editor is the priority my animation track runs on, regardless of what priority I set it to inside my script.

This is the function I use to create animation tracks (which are later played using :Play() elsewhere)

function CreateAnimationTrack(id, priority, character)

local humanoid = character:FindFirstChildOfClass("Humanoid")

local animation = Instance.new("Animation")

animation.AnimationId = id

local animationTrack = humanoid:LoadAnimation(animation)

animationTrack.Priority = priority

return animationTrack

end

I get no console errors and have verified (with print statements) that the priority I set is the priority that the track is just before it is played. I already know that the workaround is setting the priority I want on the editor beforehand, but I don’t understand why the editor’s animation priority overrides any priority I set through this function.

Examples

  1. An animation set to priority Idle on the editor still runs when I set the priority to Core in my script before playing
  2. An animation set to priority Core on the editor refuses to run with any higher priority I set in my script before playing