I really don't know why its stuttering and have no clue the only thing I noticed is that it stops for like half a second after it reaches its waypoint which I confirmed by adding an instance for the position of the waypoint, does anyone know how to fix this? The code below is used as lets say a zombie to go and smartly find a character, I have all the character finding and all that stuff down its just the patfinding acting up.
local PathfindingService = game:GetService("PathfindingService")
local NPCCharacter = script.Parent
local NPCRootPart = NPCCharacter:FindFirstChild("HumanoidRootPart)
local function Createpath(Target)
local path = PathfindingService:CreatePath()
path:ComputeAsync(NPCRootPart.Position, Target)
return path
end
local function WalkPath(Target)
local path = Createpath(Target)
print("Walking to path!")
local WayPoints = path:GetWaypoints()
for WaypointIndex, waypoint in pairs(WayPoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
NPCHumanoid.Jump = true
end
NPCHumanoid:MoveTo(waypoint.Position)
NPCHumanoid.MoveToFinished:Wait()
end
end
while true do
WalkPath(game.Workspace.EndPoint.Position)
end

1 comment
I mean I after a few minutes instead of MoveToFinished I just changed it to wait(0.15), but it kept reversing and its not really efficient, so I just want to know if something could just make it run smoothly .