Safest Route for Path Finding

So I wanted to know how can I make my Path Finding follow the SAFEST path, not the quickest. Because right now its taking the quickest which can cause it to fall off the map.

local pfs = game:GetService("PathfindingService")
local plr = game.Players.LocalPlayer.Character.HumanoidRootPart
local hum = game.Players.LocalPlayer.Character.Humanoid

local path = pfs:CreatePath({
	AgentRadius = 2,
	AgentHeight = 6,
	AgentCanJump = true,
	WaypointSpacing = 1,
	Costs = {
		Air = 20
	}
})

path:ComputeAsync(plr.Position,game.Workspace.Enpoint.Position)

for _, waypoint in pairs(path:GetWaypoints()) do
	hum:MoveTo(waypoint.Position)
	hum.MoveToFinished:Wait()
end

Any tips on how I can achieve this?

Costs, costs are there so you can highlight areas more “expensive” to travel through, if there’s a certain area, then create a part in that area and give it a pathfinding modifier. Make sure the costs and labe of the modifier is are the same name.

2 Likes

There is no part for pathfinding costs, its just straight up floating islands. How would I go about it then with costs?