I want to makes some boolvalues where I can save the data of for instance the settings in my game (for example: If I toggle the DarkMode settings on, that it will save that boolvalue to true) But I was wondering where I should put these values
Is the BackPack a good place or should I save it in leaderstats?
And another question is how can I acces and change these values then with localscripts?
You dont have to comment the whole data store because I know how that works…
I use two solutions: store values in replicated storage, or don’t put these value objects anywhere at all but store all the data in a script.
To change these values from local scripts you should use remote events.
but if you store them in replicatedstorage, are these values then for the whole server or just for that one player because I want to save these values for local players not for the server if you understand
You can make folders for each player and put these values inside for example:
replicatedStorage
plrData
player1
value1
value2
player2
value1
value2
If you do go for the value object route, storing a folder inside each player’s player object is another route you can go.
Out of curiosity, is storing it inside the player instance a good habit? Why Replicated Storage?
Ideally, what I do is store values in ServerStorage in the same format as what Kacper mentioned. But use Remote Functions to send the data between the server and the client. By storing it in replicated storage, anyone can have access to someone else’s data.
So the best and savest way is to put it in to the serverstorage, so for every player an own folder?
It’s one of the safest methods but you can also store everything in a script and not use any value object anywhere. In my recent game I implemented a system where everything was stored in a table.
They may be able to see someone else’s data, but if they modify it the changes will only be reflected in their client. The server does not see changes to replicated storage by a client.
Even if the objects are in replicated storage or a player object, only changes made by the server will replicate to other clients. If you hide the value objects from clients, you are unnecessarily doubling the remote function load of reading/writing to the values.
I’d personally suggest using tables since using instances is bad practice:
local dataTable = {
[Player1] = {
Stats = {},
Inventory = {}, -- etc
}
}
Datastore:SetAsync(LocalPlayer.UserId, dataTable[LocalPlayer])
If you would like to change you would make a boolvalue in serverstorage, and changing the values trough remote events
@visvisjes
Hey,
I would suggest you to mark this message I replied solved.
Because by storing datas of players in ReplicatedStorage doesn’t change, they can still access it.
How do I know this?
Because client can access ReplicatedStorage and not ServerStorage.
Btw I have synapse x and I tested, everyone can access ReplicatedStorage with a hack.
OR
You could just use DataStore2 and add or remove values with Increment()