Pathfinding not generating a path

Hey fellow developers. So my pathfinding script for a NPC worked perfectly a few months ago and now when I came back to it, it fails to work in my game. Also, if I put the NPC in an empty baseplate server it works perfectly like normal. Is there an explanation for this? I am totally confused. I am assuming that path:GetWaypoints() is broken or something.

Revised Post: So the problem apparently is that pathfindingservice is not generating a path in my game, but it works fine in a normal baseplate after hours of testing. Anyone know why this is the case?

Edit 2: I tried tampering with the collision editors, but to no avail.

1 Like

path:GetWaypoints() still works, could I see your code so I could see if any of it is outdated or anything?

1 Like

if position.Value == “Hiker” then
local idleanim = script.Parent.Animation1
local runanim = script.Parent.RunAnim

	local idleanimtrack = hum:LoadAnimation(idleanim)
	local runanimtrack = hum:LoadAnimation(runanim)
	
	idleanimtrack:Play()
	idleanimtrack:Stop()
	print("ok")
	if ladder ~= true then
		runanimtrack:Play()
		local pathfindingservice = game:GetService("PathfindingService")
		local path = pathfindingservice:CreatePath()--creates a path object
		path:ComputeAsync(torso.Position,vector3.Value)--computes a path
		local waypoints = path:GetWaypoints()
		
		local distance
		print("ok2")
		for i,waypoint in pairs(waypoints) do
			local waypointPosition = waypoint.Position
			print("looping!")
			if waypoint.Action == Enum.PathWaypointAction.Jump then
				hum:ChangeState(Enum.HumanoidStateType.Jumping)
			end
			hum.Seated:Connect(function(seated)
				if seated == true then
					hum:ChangeState(Enum.HumanoidStateType.Jumping)
				end
			end)
			path.Blocked:Connect(function()
				hum:ChangeState(Enum.HumanoidStateType.Jumping)
			end)
			hum:MoveTo(waypoint.Position)
			repeat  
				distance = (waypointPosition - hum.Parent.PrimaryPart.Position).magnitude
				wait()
				print(distance)
				print("waiting")
			until
			distance <= 6.05
			print("here")
		end
		print("dumbo")
		runanimtrack:Stop()
		idleanimtrack:Play()
end

For some reason the print(“looping”) isn’t printing which is so weird or anything in that for loop actually.

You said:

path:ComputeAsync(torso.Position,vector3.Value)

Why did you say vector3.Value, the path probably doesn’t know where the end goal is so it isn’t working.

It’s a Vector3.new() value I just named it vector3 that isn’t the issue lol. The issue is that the paths aren’t generating in my game for some reason. The path creations fails every time in my game for some reason. If I do print(tostring(path.Status)) the result is NoPath.

Hmm, that’s weird. I’m sorry I’m not good enough with pathfinding to help you. Good luck solving it though, I’m sorry I couldn’t be of more help.

1 Like

Thanks for your time though. I appreciate the effort.

1 Like

I have the exact issue right now for combat AI, have you solved this issue?

I managed to solve it myself. The issue was apparently some lingering terrain that was outside my map. I managed to figure this out after a bunch of testing. It was a real pain to find the misplaced terrain, but deleting the terrain fixed my pathfinding. Hope this helps!