Pathfinding acting weird

My pathfinding has been acting very weird, does anyone know why?


Here’s the code to the pathfinding:

local function MoveTo(pos)
		local char = self.model
		local hrp = char:FindFirstChild("HumanoidRootPart")
		if not hrp then return end
		local hum = char:FindFirstChild("Humanoid")
		if not hum then return end
		local path = PathfindingService:FindPathAsync(hrp.Position, pos)
		if path then
			local waypoints = path:GetWaypoints()
			if waypoints then
				local waypoint = checkw(waypoints)
				if waypoint then
					local w = waypoint
					if waypoint.Action == Enum.PathWaypointAction.Walk then
						hum.Jump = false
					elseif waypoint.Action == Enum.PathWaypointAction.Jump then
						hum.Jump = true
						w = waypoints[4]
					end
					hum:MoveTo(w.Position)
					return
				end
			end
		end
		hum:MoveTo(pos)
	end

If there is a part or something in the way of the humanoid moving then it gets stuck. You can have it pathfind and every way point move to the waypoint and then calculate a new path. This could get laggy but should fix your issue.

There is no parts in the way. And FYI, his script is running in a loop. I’m not sure why it keeps randomly jumping at certain places and moving around even when there’s nothing in the way.

I was thinking that the character/NPCs might be getting in the way. Try with just one on a flat surface.

Look in studio settings and enable Navigation Mesh, this is how you can see the path the characters take

How can I modify the paths? Is there anyway at all?

It’s not because of the NPC’s, because they already don’t collide with each other and the pathfinding service recognizes that.

yeah same issue here, cant figure it out :confused:

You would need to change the terrain and move parts around, I’m pretty sure you can’t directly change the navigation mesh sadly. Also why does your script have w = waypoints[4] for when the waypoint action is jump, what purpose does that serve?