NPC on Client or on Server?

Hello there,

I am looking to make a system where an NPC moves from waypoint to waypoint, stopping at each waypoint to collect something (Play animation) which makes the player earn money.

I am planning to spawn the NPCs on server but play the animations and move it on the client. Having said that, this means that I need an Animation.Stopped event to FireServer() so that the server can reward the player after the NPC’s collecting animation finishes.

Basically the process is this:

  1. Create NPC on server (Server)
  2. FireClient() to setup the NPC on client (Server)
  3. Load the animations required to the animation controller (Client)
  4. Move the NPC to the next waypoint (Client)
  5. NPC Reaches waypoint > Play Collecting Animation (Client)
  6. Animation.Stopped event will listen to animation finishing and FireServer() to reward the player (Client)
  7. Server rewards player (Server)
  8. Process repeats as in the NPC walks to next waypoint and procedure repeats…

Please note that the reason I have decided to create the NPCs on the server so that I can parent them on ReplicatedStorage from each client that isn’t near the NPC and vice versa.

Is this process better than just doing everything on the server i.e have the animation play and animation.Stopped event on the server? Another concern is that since I have to FireServer() (From step 5 to 6) to reward the player there can be latency between client and server which can result in delays.

1 Like

The player can just fire the remote event instantly instead of waiting for the animation. Another idea would be to do the pathfindinding on the server with a dummy object, wait the length of the animation, and reward the player.

1 Like

Mhm I can do serverchecks when I FireServer() to reward the player but there are still risks like you’re saying.