Walking animation keeps resetting

Hi people. I am having an issue where this creatures walking animation keeps on resetting as he is walking. There is no such issue in the Animation editor. My theory is that it stops very briefly at the waypoints, and so the animation script resets it. But Im not sure, please lend some advice!

Here is the animation script by Gnomecode that I am using and my AI script.

-- Very basic walking animation script by GnomeCode
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

-- Remeber to select the animtion object and set the id to your own!
local walkAnim = script:WaitForChild("Walk")
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)

humanoid.Running:Connect(function(speed)
	if speed > 0 then
		if not walkAnimTrack.IsPlaying then
			walkAnimTrack:Play()
		end
	else
		if walkAnimTrack.IsPlaying then
			walkAnimTrack:Stop()
		end
	end
end)
local creature = script.Parent
local humanoid = creature.Humanoid
local hrp = creature.HumanoidRootPart

local function getPos(pos) --decide where to go

	local x1 = (pos.X - 60)
	local x2 = (pos.X + 60)
	local xPos = math.random(x1, x2)

	local z1 = (pos.Z - 60)
	local z2 = (pos.Z + 60)
	local zPos = math.random(z1, z2)

	local newPos = Vector3.new(xPos, pos.Y, zPos)
	return(newPos)
end

local function newTarget()

	local pos = hrp.Position
	local newPos = getPos(pos)
	local PathfindingService = game:GetService("PathfindingService")

	local pathParams = {
		["AgentHeight"] = 5,
		["AgentRadius"] = 3,
		["AgentCanJump"] = false
	}
	local path = PathfindingService:CreatePath(pathParams)
	path:ComputeAsync(hrp.Position, newPos) --go there
	if path.Status == Enum.PathStatus.Success then

		for index, waypoint in pairs(path:GetWaypoints()) do
			humanoid:MoveTo(waypoint.Position)
			humanoid.MoveToFinished:Wait()
		end
	end

	local wt = math.random(1,2) 
	if wt == 1 then
		wait(math.random(0, 3))
		newTarget()
	else
		wait(math.random(1,6))
		newTarget()
	end
end

newTarget()

I came here looking for an answer because I’m having the same problem. Its been a while from what I see, did you find a solution to this?

BTW that is one hell of a monster, really cool looking

1 Like

Didn’t solve, instead I am just letting him walk continually even when standing still.

Monster model and animation is really just a mockup, though with some work and an added pair of legs I’m sure it will be cool looking