Humanoid:MoveTo() Stuttering, Lagging, Being a total mess

spawn(function()
for _, waypoints in pairs(script.Parent.Waypoints:GetChildren()) do

			local path = PFS:CreatePath()
			path:ComputeAsync(randomMinion.HumanoidRootPart.Position, waypoints.Position)
			local wp = path:GetWaypoints()
			for _, wp2 in pairs(wp) do
				randomMinion.Humanoid:MoveTo(wp2.Position)
				randomMinion.Humanoid.MoveToFinished:Wait(0.0001)
			end
		end
		print(randomMinion.Name.." finished the track")
		
		script.Parent.BuildingEntry.Health.Value -= (math.random(2,5))
		randomMinion:Destroy()
	end)
end

end

When I am using MoveTo() for my Tower Defense game, the “bad guys” are stuttering. I first suspected that It was a studio issue, but it was also present in the roblox client itself. I also tried only sending 1 “bad guy” but the problem arose again, meaning it is not an issue with roblox studio nor the amount I am sending out. Any suggestions?

https://gyazo.com/fd0d8c7c25e6dcf7b6b673f910799706

roblox finally let me add a video :slightly_smiling_face:

1 Like

If anyone was having trouble with the video (Because i sure was), what is being shown is the NPCs almost teleporting in a way, a couple of studs each time, instead of smoothly moving. And as I stated before, the number of the NPCs seems to have no effect, because only having 1 at a time is the same results…

NOTE: I know the MoveToFinished:Wait has 0.0001, that was something I was debugging with and forgot to remove, but even removing that has the same results

I’m not sure, but did you try moving the wait(.0001 is irrelevant, since wait() is always greater than .0001) to the line after the loop so it isn’t happening every time the loop is run, for every randomMinion?

Edit: sorry, didn’t see the NOTE you’d made.

1 Like
    for _, wp2 in pairs(wp) do
			randomMinion.Humanoid:MoveTo(wp2.Position)
		end
randomMinion.Humanoid.MoveToFinished:Wait(0.0001)

Like that?

Give it a try. Take out the 0.0001 though, just make it wait()

If you look at Roblox Globals | Roblox Creator Documentation you’ll see that Wait() is a minimum of 29 milliseconds, but may be longer. Wait() is the minimum time it’ll take.

1 Like

https://gyazo.com/8e9d3de6007c281ec5bed35e68866de2

It fixed it! They stop at the right stops and don’t stutter. Thanks a million

1 Like

That’s strange, I’m having the exact same problem as you with my own code and I’m not even waiting. I’m using MoveToFinished but with a function rather than waiting for it to complete.

Still having problems with stuttering, though. Do you know if they begin to stutter again whenever you walk your character really close to them? That seems to be what happens with me. The movement is fine until I’m near the humanoids. Guessing it might be a network ownership issue or something.


The stutter looks very similar to yours, I think.

1 Like

It may very well be a network ownership; that was one of the solutions I was considering before I got the solution from Scottifly. If using network ownership doesn’t work, then I would suggest using Humanoid.MoveToFinished:Wait()

3 Likes