Recently , I’ve been wanting to create a game which requires Datastore, but the only practice I have using datastore is saving values like BoolValues or NumberValues, however I heard that these value objects are highly exploitable so I wanted to switch to a new was of storing the players data.
For example:
Say I wanna keep a record of if someone bought a developer product or the new “premium Up sale” thing,
Yes you can just save them like a regular value, all you need to do is what you would normally do to save your datastore but just use your Storage variable instead
YourDataStore:SetAsync(key, Storage)
Let me know if something I said is inaccurate or incorrect.
dataToSave = {
BoughtPremium = game.Players.BoughtPremium.Value
}
local Data = game:GetService("HttpService"):JSONEncode(Storage)
DataStore:SetAsync(player.UserId, Data)
--//And when loading do it like:
local success, err = pcall(function()
data= DataStore:GetAsync(player.UserId) or game:GetService("HttpService"):JSONEncode(Storage)
end)
local loadJSON = HttpService:JSONDecode(data)
Then to get the data, you create instances (e.g. Instance.new(“IntValue”)) and then the value of that is loadJSON.BoughtPremium (or whatever the thing you saved was)
Please note: UpdateAsync may be safer to use, but I used SetAsync for the sake of simplicity.
I’m pretty sure Roblox converts your tables into JSON to store them in the first place. You don’t have to do this step on your own, just make sure not to mix string and integer keys