Why is it my walking animation keeps moving when a humanoid is still/not moving? How can I check this? It keeps walking when I leave the keyboard alone basically and am not moving sometimes.

I'm using ROBLOX animator and change the default walking animation track via starterCharacterScripts. My script only sets the animations and I have one that checks.

Any thoughts on how to fix this?

Script to check below, it's a local script: Issue with this script: When it does stop it, the humanoid will not run anymore and that makes the character stand in place and move.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild 'Humanoid'

repeat wait() until Character.Parent == game.Workspace

local function CheckWalkingAnim(tracks)
	for i, v in pairs (tracks) do
		if tostring(v) == 'WalkAnim' or tostring(v) == 'RunAnim' then
			return {true, v}
		end
	end
	return {false}
end

while true do
	local Tracks = Humanoid:GetPlayingAnimationTracks()
	if Humanoid:GetState() == Enum.HumanoidStateType.RunningNoPhysics and Tracks[1] then
		local newList = CheckWalkingAnim(Tracks)
		if newList[1] == true then
			newList[2]:Stop()
		end
	end
	wait(0.5)
end