Path finding not working?

so im making a path finding script for my boss, and it worked for a bit (btw back then i made a post about this too cuz it had an error). then i decided to mess around a bit and no errors, but path finding wont work?
idk wat the problem is but im sure its fairly new and only errored when i messed around with the script…

local path = PathFindingService:CreatePath(pathParams)
		
		if NearestTarget then
			path:ComputeAsync(newBossModel.HumanoidRootPart.Position, NearestTarget.HumanoidRootPart.Position)
		end		
		if AttackTarget then
			remote2:Fire() --ignore its just an attack remote..
			
			local Waypoints = path:GetWaypoints()

			for i, waypoint in pairs(Waypoints) do
				humanoid:MoveTo(waypoint.Position)
				humanoid.MoveToFinished:Wait(2)
			end
		else --just incase the player is not in the attack range..
			local Waypoints = path:GetWaypoints()

			for i, waypoint in pairs(Waypoints) do
				humanoid:MoveTo(waypoint.Position)
				humanoid.MoveToFinished:Wait(2)
			end
		end

Thanks!!

Did you define PathFindingService?

2 Likes

Yeah, i checked my script and i did define it…
Also, sorry for the late reply

Do you have any errors in the output? If so what are they?

1 Like

None, just the boss not moving…

Try printing the path status and see if there is a problem by doing:

print(path.Status)

Also, in the else statement you are doing the exact same thing in the first condition?

1 Like

Yeah, its just doing the exact same thing…
Ill try printing path.status when? After the if statement or?

After you compute the path. (30char)

1 Like

Ill try it when i get to my computer!! (Its dinner for me rn srry)

Printed path.Status and it says nothing, it doesnt print out at all?

I fixed the problem, i had an if statement that was impossible to be true, so i deleted it and it works now!! I decided to check my whole entire script after @Fusionet told me to print the path’s status and it didnt print, printed nearesttarget and it was nil, decided to check where the nearesttarget was returned and before it returned it had the if statement (it was impossible to be true since it checks if the player is in the arena but i removed it)

Thanks everyone who helped me!!

1 Like