Improve pathfinding without using loop?

I’m currently making an AI pathfinding with FOV vision using dot product (vision code here).

I’m also using SimplePath for the patrolling system and I wanna ask if I can improve the code to make it more performant and efficient when chasing the player:

path:Run(pickRandomPath());

path.Reached:Connect(function()
	if not PLAYER_BEING_CHASED.Value then
		path:Run(pickRandomPath());
	end
end)

path.Blocked:Connect(function()
	warn("Path got blocked")
	path:Run(currentPath);
end)

path.WaypointReached:Connect(function()
	if PLAYER_BEING_CHASED.Value then
		path:Run(PLAYER_BEING_CHASED.Value.Position)
	end
end)
task.spawn(function()
	while task.wait(0.08) do
		if checkSight(monster) then
			if path.Status == "Idle" then
				path:Run(PLAYER_BEING_CHASED.Value)
			end
		else
			PLAYER_BEING_CHASED.Value = nil
		end
	end
end)

I don’t think you need this part of the code right? Seems like just some extra pathfinding for no reason.

image

I added that cause ­ path:Run­ ­ does not account for moving objects. You could argue that I could remove the:

if path.Status == "Idle" then

and just leave it as is but it will make the movement of the bot really choppy

im using simplepath to run like 150 bots and its not too bad. im using a loop as well. you can test it here to see. but dont kill them right away lol

Hey I js found a way to reduce server load a lot more. So you have to use agent parameters, and apply them to the pathfinding. these are my parameters:
image
the important one is waypoint spacing, the rest can be up to you. basically, the waypoints are made as far away from eachother as possible. so a lot less waypoints means much better performance. I saw a 2x increase in performance from the server.

you can check your performance by opening “script perfomance” in the roblox view panel, viewing the running game from the server, and it shows the stuff