Npcs developed conciousness just to defy a pathfinding modifier

Pathfinding Modifiers are being ignored

So, that title sounds crazy, I know, but I mean it’s what I am experiencing.

I made some okay-ish NPCs and they do as much as I made them be able to do: talk set lines and walk to random destinations like going to the city centre or going to the park to stand there for a minute or so and go to another point later.

So, as I said, they like to walk around the city and, as we people know, any city has a road, at least a single one, and my city isn’t an exception. It has many roads, and roads are terrain, but I have to add that the roads have a part over them and under them (around 30 studs tall) completely covering them, and the part has a Pathfinding Modifier that has its label set as Road.

But when the NPCs are wandering around the city they just ignore the modifier and cross the road. Keep in mind I’m no dictator—I keep crosswalks reasonably close—but I’ve seen them cross the road a meter away from a crosswalk.

Script

local Humanoid = script.Parent.Parent
local activities = workspace.NPCspawners.Hotspots
local pathfinding = game:GetService("PathfindingService")
local path = pathfinding:CreatePath({
	AgentRadius = 2,
	AgentHeight = 6,
	AgentCanJump = true,
	AgentCanClimb = true,
	AgentJumpHeight = 2,
	AgentMaxSlope = 45,
	AgentMaxJumpDistance = 5,
	WaypointSpacing = 1,
	Costs = {
		Crosswalk = 0,
		Road = 543879239205848, -- have tried math.huge didnt change anything
		Concrete = 2,
		Water = 7,
		Grass = 2,
		Pavement = 0,
		Climb = 3,
	}
})

local currentcity = "Valentine"

local currentactivity = nil

local function chooseRandomActivity()
	local activityFolder = activities:FindFirstChild(currentcity)

	if not activityFolder then
		warn("No activity folder found for city:", currentcity)
		return nil
	end

	local activityList = activityFolder:GetChildren()

	if #activityList == 0 then
		warn("No activities in folder:", currentcity)
		return nil
	end

	local NewActivity = activityList[math.random(1, #activityList)]

	local children = NewActivity:GetChildren()
	return children[math.random(1, #children)]
end

local function PathFindToLocation(location)
	path:ComputeAsync(script.Parent.Parent.Parent:GetPivot().Position, location)
	local waypoints = path:GetWaypoints()
	
	for _, waypoint in ipairs(waypoints) do
		Humanoid:MoveTo(waypoint.Position)
		Humanoid.MoveToFinished:Wait()
	end
end

while wait(30) do -- short number just so they think quicker
	local Decidedactivity = chooseRandomActivity()
	PathFindToLocation(Decidedactivity.Position)
end

the script looks weird, its because of it being under another script because of my laziness



in the screenshot it may look like theyre not that tall but ive tried with tall ones too but doesnt work either