Pathfinding agents dont listen to material costs and decide they all want to die

My pathfinding agents decide to walk on the neon even though its material cost is higher?


local npc = script.Parent
local hum = npc:WaitForChild("Humanoid")
local walking = false
local debris = game:GetService("Debris")
local walkani = hum:LoadAnimation(npc.Animate.walk.WalkAnim)
local path = pathfindserv:CreatePath({
	agentcanjump = true,
	agentcanclimb = true,
	agentradius = 15,
	Costs = {
		Plastic = 1,
		Neon = 100,
	},
})


while true do
	if walking == false then
		local goalpart = Vector3.new(math.random(-10,10),10,math.random(-10,10))
		local success, error = pcall(function()
				path:ComputeAsync(npc.HumanoidRootPart.Position, workspace.Area.Position - goalpart)
		end)	

		if success and path.Status == Enum.PathStatus.Success then
			local part = Instance.new("Part")
			part.Anchored = true
			part.Material = Enum.Material.Neon
			part.CanCollide = false
			part.Color = Color3.new(0, 1, 0)
			part.Shape = "Ball"
			part.Position = workspace.Area.Position - goalpart + Vector3.new(0,13,0)
			part.Parent = workspace
			debris:AddItem(part,3)
			walking = true
			walkani:Play()
			for i,waypoints in pairs(path:GetWaypoints()) do
				local part:BasePart = Instance.new("Part")
				part.Material = Enum.Material.Neon
				part.Anchored = true
				part.CanCollide = false
				part.Shape = "Ball"
				part.Position = waypoints.Position
				part.Parent = workspace
				debris:AddItem(part,3)
				hum:MoveTo(waypoints.Position)
				if waypoints.Action == Enum.PathWaypointAction.Jump then
					hum.Jump = true
				end

				hum.MoveToFinished:Wait()
			end
			walking = false
			walkani:Stop()
		else
			warn("cantcreate")
		end
	end
	wait()
end

maybe its a smoothplastic? :skull: (lowkey would be funny if its the problem)
Try setting cost to 0 or negative.
You should add more barriers to that or increase AgentRadius so it takes larger distance between neons

There are a few reasons why your agents might try to go over the neon parts.

  1. Agents might be trying to jump over corners. You can stop it by setting the AgentCanJump property to False. (I highly doubt that this is the reason)

  2. Try using math.huge in the pathfinding costs, when you don’t want Agents to go over certain parts.

  3. Try defining the AgentHeight property.

  4. You can also try changing the AgentRadius property. 15 is quite large for a normal sized rig.

  5. There is also the possibility that the floor material is SmoothPlastic not Plastic. Try changing it.

Hope this helps. (^_^)