Is there a way to make Pathfinding service work on client?

Hello,

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?

1 Like

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:

  1. Use a server script & everyone can see it.

  2. 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.

  3. 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.

1 Like

Thank you for the reply,

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.

1 Like

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 have tried it on a localscript first, but it never returned anything on :GetWaypoints() function, but works fine on server script.

How do I contact DevRel?

I think you can message them on Developer engagement team - Developer Forum | Roblox . I’d double check and be sure before you message them just to be sure it’s not an error on your part.

1 Like

I will try it again when I get home, I will try to pathfind at a position that is nearer to the player and if that doesn’t work again I will be contacting them. :slight_smile:

1 Like

Path finding service can be used on a client I tried doing it for my game just to test around with a more accurate click to move system.

2 Likes

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.

Thank you both of you for the replies :smiley: