Hey everybody! So I’ve run into this same issue time and time again and it’s really stumping me. I’ve looking at scripting helpers, and here for solutions, yet I can’t seem to find anything that works. Yes, I’ve tried removing the finished event and using distance to move to the next waypoint, but that doesn’t even work. The issue, my friends is that when you create a long enough path, the AI will follow, but it will constantly stutter along the path. What in the heck is going on and how do I fix it?
Here’s my code:
local newAi = api.SpawnFunc(player)
local newAiHum = newAi:FindFirstChild('Humanoid')
newAi.Data.Target.Value = player
local newPath = pfs:CreatePath()
local waypoints = newPath:GetWaypoints()
for i, waypoint in pairs(waypoints) do
local waypointPosition = waypoint.Position
distance = (waypointPosition - newAi.PrimaryPart.Position).magnitude
distance <= 4.6
I would stick to using the distance event. However, try setting your distance threshold to 10 and see if the stuttering happens. I can’t see much of an issue so trial and error is probably your best bet. I would go back to using the distance threshold instead of the Finished event as well.