Pathfinding Service | How can I create all of these paths at ease?

I am wondering how I can use pathfinding service to go about creating these routes with ease. The routes can be as long as you want and you can have as many routes as you want. The object will start at point “1” and go to point “2” and so on. Each point can have multiple routes that it can lead in. The problem is that I am having trouble formulating code to accomplish this goal. Can somebody please help guide me?

My model is currently set up like this but it can easily be changed since I dont really have much to any code for creating these paths.
image

In the image above, our object starts at point 1 and needs to go to point 2. Since there is multiple “2” points, it will choose a random 2 to go too and go to that point. After that it will repeat the process and go to 3 and so on. But when you have a bunch of long paths and numbers it can get confusing. So I am wondering what is the best way to go about this and if I can get examples.

1 Like

It’s probably more helpful (and easier to work with) to just store these points as graphs. If there are no obstructions are gaps between points, you can just use MoveTo or TweenService. If there are, just use PathfindingService to find a path between the two points you want.

Interesting. How can I put that into code though? I can do the pathfinding and tween service but understanding the graphing and putting into code is what is confusing to me.

There are a lot of ways to store graphs in code. https://www.youtube.com/watch?v=c8P9kB1eun4
Graph (abstract data type) - Wikipedia Granted, all of these talk about graphs in general, not just Luau, but hopefully you can apply it yourself.