Question about data system

If I’m making a client DataService that stores the data sent by the server, If I want to modify that data in another client script/module, should I just directly change it like:

player.Data.Settings.FieldOfView = 90

The problem with above is that this means other scripts could accidently mess with it and break the data.

Because my data structure has a bunch of nested tables right now and I don’t even know if it’s possible to make a function to help me set the value of a data key.

How should I handle this?

1 Like

I’m pretty confused on what you are trying to achieve here. Do you mean that your current system is:

  • Retrieve data on server
  • Send data to client (through remote event I assume)
  • Update the player’s settings in a folder with BaseValues

How would a script be able to “mess” with the data?

Is this an instance you are indexing? Is this part of a module?


For general advice:

  • Retrieve data using one script
  • Store data in ObjectValues, attributes, or a module
  • Access data by taking the value from the ObjectValue, attribute, or module
  • Do not change data on client (won’t save anyways)
  • Save data when the player leaves or the server shuts down (game:BindToClose()) on the server
  • Never trust data sent by the client to the server; can be exploited (doesn’t matter for basic things like volume settings)

pretty sure he just means something like two scripts indexing and setting it at the same time

its not an instance lol you cant access .Data without requiring the module first

and OP you should be storing FOV on the server and telling the server to change it from the client because it wont save on the client like above says

im assuming it looks like this

maintbl = {
 idx = {
  idx2 = {}
 }
}

and if it looks like

maintbl = {}
maintbl.idx = {}
maintbl.idx2 = {}

just change it to the first because you shouldnt index user settings this way

definitely possible, just do a numerical iteration because luau can index numbers better

for idx = 1, #tbl do
 local currentIdx = tbl[idx]

 -- do what you will with currentIdx
end
1 Like

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