I made a client hostile but how do i keep track of it in the server

like i said in the title i made client hostile but if the hostile is attacking / following a player how do i make sure that every player see the hostile in the same spot
the server handles the target position and health but how do i keep track of its position so that i can make sure that every player sees the hostile in the same place without making too much lags (using too much memory)

1 Like

Do you mean that there is something hostile on the client, or that the player is hostile?

Is the hostile movement/attack done server-sided or locally? If it’s done on the server everyone can see it.

We need a little more info to help you here.

everything is done locally exept the health of the hostile npc and the where the npc will go everything related to movement and being loaded to the workspace is done locally

no a hostile npc that is operated by local script to increase performance

ok its a client sided npc and i want to keep track of the npc cuz i want to solve the problem that the npc is not syncronize between players
for exemple the hostile npc can attack player1 and follow him to a another place on the map
but in the middle of the fight a new player (player 2) joins the game and just see the hostile npc in their spawn trying to follow player 1 but in reallty the hostiles are already attacking player 1 far away from thier spawn so my question how do i keep them syncronize even tho its is done only by local script

If you want everyone to see the same thing you need to make it done on the server. Unless you choose to use RemoteEvents to update the position of the enemy on the server.

I wouldn’t recommend doing that, as that would likely decrease performance as it would rely on the specs of the user’s device

quite the oppsite it will increase the npcs smoothness becuase its on the client

But it will take up a lot more memory and CPU capacity…
Even if you chose to use RemoteEvents, it would require the player to have a good internet connection.
There’s no point in doing that on the client.

1 Like

thats why im asking for away of optimizing it cuz even if you chose to do it server side it still lacks the capability of moving all the hostile npcs smoothly even if you remove their humanoids and tween them or even make the networkownership to the server/client
thats why i choose to do it locally cuz when you do it locally you get the best performance the npc will become the smoothest it can from what i can understand GPO and Deepwoken are using it locally cuz they have many npcs around the map so to get to their performance they had to do it locally

The only way to optimise it is to give everyone 0ms ping aka breaking the laws of physics.
Doing it with RemoteEvents is the only way, but it would be laggy for all other players.

devs already figure this out there are a lot of devs that make npcs locally and figure this stuff out
my idea so far is to have a client responsible for the hostile location and if a new player join just get the position form the responsible client

I have no time to argue with stuff like this. It’s literally what servers are for - to connect clients together.

in a perfect world i would agree but in roblox the server is slow and dont have a lot of memroy so if its possible its nned to be in the client to increase prefomance and give the server more “space”

That’s completely wrong. The server has way more than enough memory to handle an npc, it tends to struggle a bit sometimes, but it’s far more common for the client to be laggy and to have low performance.

1 Like