Hello, I’m trying to create my first NPC system (for a monster). But I don’t know if the right way to do it is to manage the detection of the players (with Dot and the magnitude between the NPC and the players character) on the server, looping all the players and detecting the closest one to act on it, or if I should loop all the clients locally, and if the monster is close to the client character then I send a remote event to the server and depending on the different results I decide who the monster is chasing? I’ve started managing them all on the server because I find it easier and more intuitive, but I don’t know if it’s the right way to do it.
Detecting it on client side would result to a false detections, more server ressources taken, wrong calculations and open bar to exploiters lol
If you do the detection in client side, it mean there will be as much Remote events fired / received as how much players there are in the server… so the server will eventually receive too much informations at a time and it will be a nightmare to do the calculations.
Also people can easily exploit it as you probably are going to put the monsters, players object, root or even positions into argument… they can edit that to whatever they want.
Then to make sure they aren’t exploiting, you have to do some sanity check like magnitude, is it the right monster, the right player character ect… which is the exactly same result as doing it directly on the server, it can even maybe be harder to do.
So i think you should mostly handle the detection only onto the server, and do one loop that check all the NPC at same time and check if a player character is in range, then take the closest one and make it run to it and attack or whatever you want to do.
Alright thank you for your help. That exactly how i do it, with some others elements. I’m relieved I don’t have to do this locally, in fact I don’t even know exactly how I could have done it. Thanks again for the useful informations !