How to make an animation play only when the Npc is moving

Hi all
I am making a horror game and i want a certain animation to play only when the npc is movingso how do i do that

this is the animaton script

local animation = script.Animation
local humanoid = script.Parent.Humanoid
local animator = humanoid.Animator
local Running = animator:LoadAnimation(animation)

Running:Play()
Running.Looped = true

also i might not respond for some time

You can use Humanoid.Running to detect if the npc is walking or not.

humanoid.Running:Connect(function(speed)
    if speed > 0 then
        print("Player is running")
        Running:Play()
    else
        print("Player has stopped")
        Running:Stop()
    end
end)