Roblox pathfinding is completely broken?

Hi,

It may sound very silly and i might have looked over something but for some reason pathfinding seems to just be completely broken. My script works like it’s supposed to but it just doesnt generate a valid path or something i think?

local PathfindingService = game:GetService("PathfindingService")
local Girl = workspace:WaitForChild("MagazineGirl")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local Path = PathfindingService:CreatePath()

local waypoints
local nextWaypointIndex
local reachedConnection
local blockedConnection

local function CalculatePath(destination)
	print('calculating')
	local success, err = pcall(function()
		Path:ComputeAsync(Girl.PrimaryPart.Position, destination)
	end)
	
	if success and Path.Status == Enum.PathStatus.Success then
		waypoints = Path:GetWaypoints()
		
		if not reachedConnection then
			reachedConnection = Girl.Humanoid.MoveToFinished:Connect(function(reached)
				if reached and nextWaypointIndex < #waypoints then
					nextWaypointIndex += 1 
					Girl.Humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
					CalculatePath(destination)
				else
					reachedConnection:Disconnect()
				end
			end)
		end
		
		print('moving to')
		
		nextWaypointIndex = 2
		Girl.Humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
	else
		warn('no path computed', err)
	end	
end

CalculatePath(Character:WaitForChild("HumanoidRootPart").Position)

Thanks in advance!

reachedConnection must not be false?

Must not be nil. The script gets past this point tho.

Pretty sure it would print “Moving to” even if reachedConnection is true. I may be wrong.

It might, let me test. But still, im telling the script to move to the point and it just doesnt for some reason??

EDIT: I check all of the properties. Nothing is getting in the way.

Make sure the npc is all unanchored.

Pls read my post correctly. I did all of those steps already.

Might be a silly one but is the a walkspeed > 0

Nope, checked as well already.

Network ownership maybe??? 3030303

2 Likes

Hmm… Let me try that really quick.

Thanks, it worked! You saved a lot of time!

1 Like

Haha didn’t think it would actually work. Glad you fixed it.