Choosing the Destination (BasePart) with Some Logic

Hey, everyone, I have come across this interesting problem. My dumb self cannot think of a solution, so I am asking here. Let’s see:

I have a map made up of 32,000 tiles (BaseParts) and I have NPCs which sometimes need to go to a certain part of a different color. The current system loops through all of the parts and finds the closest one to an NPC with a specific color. This system leaves some kind of “paths” when it recolors its destination to the color of its own, as shown by the first image.

I need the NPC to loop through all parts (with a minimal amount of Raycasts, if possible) and assign the destination, which would prevent the “exclaved paths”, as shown by the second image.

Any help would be gladly appreciated! Thank you.

Bumping this post, because I still have not come up with a solution…

1 Like

Is there any particular reason why you aren’t using pathfinding service?

1 Like

I am trying to get the Part that it shall color, not the Path that it should walk.

1 Like