Config variables client and server

I’ve been seaching for a while but cannot seem to find an answer to this. I have a table/array in the config.lua and some values get updated as things happen within the script. I want to make sure that those changes get passed to the server side of the script (easy enough) and then back to all the players so everyone has a synced version of the table. That’s what I am not sure how to do. I’ve tried a couple of things like calling a client event that loops through all the players and update the table but it doesn’t seem to do what I want. So much of scripting for fivem stuff is guess-work and trial and error. If someone has done this or knows how to make this work, please let me know. Thank you.

That’s not really a good start, your config values, generally, should be constant.

Can you show some code, sending an event to all the clients is typically the best way to go about it.

The easiest way to do it would be to send it to everyone like this: (server-side)

TriggerClientEvent('eventName', -1, table)

And then receive it on the client like this:

RegisterNetEvent('eventName')
AddEventHandler('eventName', function(table)
    Config.something = table
end)

The -1 indicates that it will be sent to all clients.

Now, I don’t know what data you are sending but you should always as a rule of thumb never trust the client and always have checks on the server-side. Good luck coding! I hope this helped.

What I ended up doing is keeping the data on the server side and just creating event functions to call from the client side when I needed the data or needed to update the data. That was a better solution anyway. Thank you all for the help.

What did you do, what’s the code?

Im using Config.ItemsAdded = Config.ItemsAdded + 1 server sided as a trigger when someone presses E on the location, but it remains on being 0