How To Make Pathfinding Service Only Go Above Certain Objects?

You use costs to make the pathfinding avoid certain materials and any object with pathfinding modifiers where you have to label the parts so that the pathfinding can avoid it, how can i use costs so it can only go on a specific label? for example i want a car to go only on the streets and not the sides.

You can just put every thing thats not a street into a folder then loop through every descendant in that folder and set it to math.huge cost

So put large CanCollide blocks on the areas that aren’t streets and make their cost math.huge. This is explained at the bottom of the Pathfinding documentation in the Work With Regions section.

@talis783 if there were a million parts that weren’t streets that’d slow down your pathfinding and your game to a crawl.

the problem is that the map is unknown, so i want to iterate on all the streets in the map, and make the car only go on the street part

Is it random generated, or does the player build the map their own way?

the player changes the map however they want.