You can just PM me on the forums, but I can’t promise I’ll respond quickly.
is it possible to require the module on client and use it as i would on the server?
Datastores don’t work on the client.
DataStore is not supported for LocalScript, however you can get it through remote events!
How would I perform rollbacks on data for a game that uses Datastore2?
There is no built in way to do this–DataStore2 containing older data should be seen as an implementation detail, not necessarily as an exposed feature.
How would I use :Increment() to update just one value in a table I have saved?
if it is to add a value use this
local DataStore2 = requiere (DataStore2)
DataStore2.combine ("MasterKey", "Money")
local MoneyData = DataStore2 (Player, "Money")
MoneyData:increment (1,0)
--- 1 increment
--- 0 initial value
I know but I want to increment one value that’s in a saved table.
local minerValues = minerSave:Get({
"Cheap Robo Miners",
0,
"Robo Miners",
0,
"Buff Robo Miners",
0,
"Robo Drill Miners",
0,
"Buff Robo Drill Miners",
0
})
That’s my save and I want to increment just one number at a time by one, so the way I was thinking of doing it was just setting it every time to have the numbers be a physical value’s value and just increment the one I need or to have an on update function for the physical values that updates/sets each value in the table, but it would be much more effecient to just increment it.
This makes dealing with data so much less painful. Thank you so much!
Please correct me if I’m wrong, but when retrieving values within a table like this, wouldn’t you have to use :GetTable()? This will use the default values in the table if it doesn’t have certain keys instead of simply checking whether or not the table exists like :Get() does.
I really don’t need a default since the default is zero anyways, but I suppose I could use GetTable…
You can’t. Just get the table, add to it, then call Set.
Is datastore2 binded to when the game closes?
Yes, I’ve tested shutting the game down and it works and saves.
Ive just realised that I’ve used the data store very inefficiently. I didn’t know .Combine can then have multiple parameters afterwards rather than just a single stat. So I used .Combine for an individual player for every stat they have. Is this an issue? Would performance be better if I used combine with multiple parameters once or used combine for every stat they have.
Also, I’ve used the function to grab the specific stat store such as coinStore every time I needed it to be changed. Would it be better to store coinStore as a variable within a module script with the player name as the key?
“Performance” meaning? It’s just an ergonomic issue, not a performance issue.
No. Just use DataStore2 every time.
Not sure if I used the term performance correctly, but would using this method:
DD2.Combine(Key, “Points”, “Kills”)
Be better for speed than:
DD2.Combine(Key, “Points”)
DD2.Combine(Key, ”Kills”)
I’m not quite sure if this is EXACTLY what I did since I’m on mobile right now but I never remembered using .Combine with multiple parameters.
Regarding the module idea to store the stats for example “statStore”. I was thinking of setting up a module where a table is created when a player joins and holds data in the structure of;
module.Tbl[playerName] = {
points = DD2(“Points”, player)
coins = DD2(“Kills”, player)
}
And then adding a module.RequestData(player) function to access this. If you believe that this method would be significantly be beneficial in terms of “speed” and “data limitations” to the point where I have to redo my current data structure, then I’m more than happy to restart my data structure.
Ps. Sorry for the lack of formatting I’m currently on mobile and doing everything from the top of my head.
Maybe by a microsecond, so it doesn’t matter. Don’t micro optimize without actually profiling, it’s pointless. Choose whatever is more readable to you.
How can i save tables without looping through the DataStores like the normal DataStore