Yo, hello everyone. I have a problem with my custom NPC, he switches from a variety of animations depending on walkspeed and other statuses. The issue is that in studio all works fine, but when doing a Team Test or testing in the actual game, the walk animation kinda like stutters/repeats itself very quickly. This only happens for this animation, and only when inside the real game or in a Team Test, otherwise it plays properly.
Here are some gifs to show the issue as im out of ideas on trying to fix it or why its happening:
-This one is how it should play

-This one is the bugged anim inside the game or team test

The animate script inside the model:
local npc = script.Parent
local humanoid = npc:WaitForChild("Humanoid")
local animsFold = npc:WaitForChild("Animations")
local walkAnim = animsFold:WaitForChild("Walk")
local runAnim = animsFold:WaitForChild("Run")
local walkTrack = humanoid:LoadAnimation(walkAnim)
local runTrack = humanoid:LoadAnimation(runAnim)
humanoid.Running:Connect(function(speed)
if speed > 2 and speed < 14.5 then
if not walkTrack.IsPlaying and not runTrack.IsPlaying then
runTrack:Stop()
walkTrack:Play()
end
elseif speed > 15.5 then
if not runTrack.IsPlaying and walkTrack.IsPlaying then
walkTrack:Stop()
runTrack:Play()
end
elseif speed < 2 then
if runTrack.IsPlaying or walkTrack.IsPlaying then
runTrack:Stop()
walkTrack:Stop()
end
end
end)
I also want to add that the run animation plays fine even inside the game and team test, so the transition between animations seems to work just fine, its just that the walk anim is acting weird. I also checked that its properly looped and all.
Any help is greatly appreciated, cheers