Data Store Client-Side Best Practices

Hi, I’m interested in knowing what some best practices are for retrieving server-sided data from the client and more importantly securely modifying data from the client.

Retrieving data

Something that I do for retrieving data are along these lines.

-- local script
DataEvent.onDataChanged(function(newData)
-- body
end)

This event would fire whenever the character is loaded or when their data is modified. Lately though, I feel like there is a better alternative out there that will increase overall performance but I’m not sure exactly where to go with it.

Modifying data from client

Usually when I modify data from the client, it’s because it’s some kind of state has to at least be readable by other sources. Example:

local blocking = false


eKeyPressed(function()
  blocking = true
  DataEvent:FireServer("blockstate", blocking)
end)
-- do the opposite for released e key

One way that I know of that’ll prevent other data from getting modified is to make a table of all your modifiable keys and check to see if the key is modifiable. But one problem I still have with this example is, when it comes to server side, I’m not really sure how to check the player is actually blocking rather than firing the remote event directly. Also firing the server whenever someone presses a button seems like another thing that’ll heavily affect performance.

Additional question for server side

One thing I like do to whenever data is changed, is to run a table of functions. For example a levelUp() function. Right now, the function prototype is

function addDataChangeSignal(player: Player, onChange: (player, newData) -> ())

My question is, should I rename this function? I’m not really sure if it can be classified as a “signal”. Also, should I leave out some of these parameters? Should I add any new parameters like changedDataName?

Thanks in advance for any help.