Animations stop playing after a while

I have a NPC in my game which is animated using the code below:

local Pool = {9947578250}

local Humanoid = script.Parent:FindFirstChild("NPCHumanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator")

local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://"..Pool[math.random(1,#Pool)]

local AnimationTrack = Animator:LoadAnimation(Animation)
AnimationTrack.Looped = true

AnimationTrack:Play()

However, as seen in this video, once the player approaches the wizard the animation will stop. I can’t find a cause for this as i have the humanoid root part anchored and have tried some other things to no avail. If there is a solution that still prevents pushing the npc (and preferably not just having players phase through) i’d like to hear it.

Instead of

AnimationTrack.Looped = true

why not just turn the loop on when editing the animation?

I believe according to docs this was the new way to do it, i’ll look into your solution and edit this when i get home though.
Edit: no success
Edit: tried again, worked now!

I have just had the same problem.
I had to set the animation on looped inside the editor and the animation track on looped with track.Looped = true
After that everything worked again