So what I want to achieve is to make PathfindingService work on client through LocalScripts, while this script wouldn’t move a NPC or anything but just visualise a path to the player’s target from their current position.
The problem is that the script isn’t creating a path while it is on client but it does it well on the server, I do not want to let the server take this task because of performance issues for the reason that the client would have to request the path every second or so to update it “real time”, making the server do a task that could have been easily done on client.
What currently happens is, the script tries to create a path but it creates none, so the visualise function cannot create any parts on the map because the :GetWaypoints() returned nothing at all on client. (The path has been computed above this line of code, this works fine on server but not on client.)
I do not have a code snipet to provide due to it being the same script from the example on the site.
Is there anyway to achieve this on client without the client firing a remote and waiting for a response with the path table?
This may be wrong so, take this with a grain of salt.
If I remember correctly, PathfindingService doesn’t replicate which would mean you have three options:
Use a server script & everyone can see it.
Use a local script with a system of events that can be sent to every client. You could in theory send the starting position of the humanoid or non-humanoid and then, have the client process the actual movement to save server resources. But, that sounds quite painful.
Create your own pathfinding API and see how far that gets you. The pros of this would be more developer freedom, design choices, & an API that conforms to your style. Cons would be the loss of mental stability, loss of time and the occasional migraine combined with frustration and bouts of words I can’t say on the forum.
So what I am understanding is that there is no way to use PathfindingService on client, and my only solution is to ask the server to do it for me then send information back to the client and visualize it there?
I want only one client be able to see this said path and not everyone on the server.
If you only want the client to see it, you could try to do it on a local script. I haven’t attempted it but, the docs don’t say that it can’t be used on a local script. If it turns out you can’t use it on a local script, might want to let DevRel know so it can be corrected. If all goes well, hopefully, you find what you’re looking for.
I figured out the issue, the problem was that the position I was trying to pathfind to was too far away from the streamed map since I got streaming on, because of it the CreatePath() could not find a possible way to get there resulting in the visualize function not working.