Humanoid.Running stuttering with PathFindingService

Issue:
When I’m in Studio, the NPC moves smoothly with no issues. In Roblox the NPC starts and stops constantly giving a stutter effect.

What I think:
It might be .Running event firing with 0 value for every waypoint reached, but I’m unsure how I’d get around it, if that is the case.

I use this simple walking script with Humanoid.Running:

local isWalking = false

Humanoid.Running:Connect(function(speed)

	if speed > 0 and not isWalking then

		StopAnimations()
		isWalking = true
		Walk:Play()
	elseif speed == 0 and isWalking then

		isWalking = false
		Walk:Stop()
	end
end)

And this is the pathfinding script: (Not all but just the necessary part)

for i,v in pairs(Path:GetWaypoints()) do
	Humanoid:MoveTo(v.Position)
	Humanoid.MoveToFinished:Wait()
end

Note: I have set all NPC BaseParts networkownership to nil.

1 Like

Depending on the pc, the client replication of the NPC could be making it laggy. Does it smooth out if you set Network Ownership of the NPC to the server?

Edit* I fixed it with an alternative.
Instead of having a seperate walking detecting script, I just started the animation inside the PathFinding function and stop it once it reached it’s destination.

if not isWalking then
	isWalking = true
	Walk:Play()
end

for i,v in pairs(Path:GetWaypoints()) do
	Humanoid:MoveTo(v.Position)
	Humanoid.MoveToFinished:Wait()
end

isWalking = false
Walk:Stop()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.