Hello. So I’ve been working on an AI script and lastly all I need is an animation part that detects when the humanoid moves. The way I have it set up is by changing the walkspeed when detecting a player, this will make the .Running function play the ‘runAny’. If the walkspeed is not 25 and greater than 0 then it plays the moveAny. This works however it stutters and plays a split second of the running animation and then constantly restarts. The weird part is that this works fine testing in studio but testing in the actual game, it stutters. I’ve tried many different versions of this but they all have the same outcome.
npc.Creature.Running:Connect(function(speed)
if speed <= math.round(speed) and moveAny.IsPlaying == false then
moveAny:Play()
if runAny.IsPlaying then
runAny:Stop()
end
if not footstepSound.IsPlaying then
footstepSound.PlaybackSpeed = 1.3
footstepSound:Play()
end
elseif speed > math.round(speed) and runAny.IsPlaying == false then
runAny:Play()
if moveAny.IsPlaying then
moveAny:Stop()
end
if not footstepSound.IsPlaying then
footstepSound.PlaybackSpeed = 2
footstepSound:Play()
end
elseif speed <= 0 then
runAny:Stop()
moveAny:Stop()
footstepSound:Stop()
end
end)