Is it safe to give clients the table containing game-related data?

Hello everyone! In my game I have a module script which contains a list of all current NPCs and a function which returns it. So, is it safe to give this table to client?

The example of script:

local module = {}

NPCs = {
    Dummy = {Health=96}
}

function module.GetNPCs()  -- accessable by both client and server
    return NPCs
end

return module
1 Like

I think it depends on the purpose of the table that client holds.

  • Any change that client does to that module table wont replicate to server.
  • In order to update that table from server to client as reducing health, wont reflect on all player’s modules tables unless you use a remote or if the module is in the “bridge” as a folder that client and server can interact as ReplicatedStorage.
  • Its perfectly fine to give tables for references to clients that are a clone from the one that server holds, but, thats just for reference, not for handling important mechanics of the game

As long they aren’t able to directly modify the server-side version of the table on the client it most likely won’t cause issues. However, when designing anything related to data replication it’s often a good tactic to apply your game logic to it. For example, instead of sending all the NPC data, you can only send the data that is currently visible to them, which you can determine by distance from their character and such.

Basically only give them the data they’re supposed to be able to see and have access to, or else exploiters might use it to gain extra powers that you don’t give them by default(for example an x-ray ability).

1 Like

Thanks for the feedback! But I have one question. Is it worth making server calculate additional things such as displaying corrent npcs in order to fight exploiters? By that I mean minor things such as x-ray for example not things like shooting through walls or teleporting

If the NPCs are important for the game mechanics, of course many data about them should be handled by server. Your question is a little vague, it really depends on your system and idea of the game mechanics.
Honestly for something that can avoid x-ray is pretty hard, depends on what we think is an x-ray…
Any client has control of its camera, control of the transparency of all the parts as walls, they have no control over the raycasting performed by server so thats a pro. If you give them references of the NPCs in game its not really important for me, cause even if you dont give those references they can easily find all NPCs in game and set their cameras, walls etc to do whatever they want. It totally depends on your game mechanics and what you want to avoid they do which is important

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.