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:
- Create NPC on server (Server)
- FireClient() to setup the NPC on client (Server)
- Load the animations required to the animation controller (Client)
- Move the NPC to the next waypoint (Client)
- NPC Reaches waypoint > Play Collecting Animation (Client)
- Animation.Stopped event will listen to animation finishing and FireServer() to reward the player (Client)
- Server rewards player (Server)
- 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.