I am a bit confused on backups. I have my data working just fine, saving and loading and now am looking to implement the backups.
coinStore:SetBackup(3)
If it reaches the maximum amount of retries, does it just prevent data from saving? Also it says it will set the value of the data store to the value provided. Does that mean if the game fails to get its data X amount of times, their data will become nil if no value is passed? Confused I am.
For anyone who wants to stay up to date on DataStore2, I’ve now made a thread that you can watch to get notifications without having to watch this thread.
I do have to say, I love this post, this is a great asset for my game. It completely changed the way my data-saving works and has seasoned my skills with proper data-store usage. After fiddling around with it, I figured out how to implement it into my new upcoming game. Bravo, and great job! Keep up the excellent work
I’m attempting to use DataStore2 in a new game of mine but I keep getting the following error:
ServerStorage.DataStore2:351: attempt to perform arithmetic on a table value
Stack Begin
Script 'ServerStorage.DataStore2', Line 351 - function Increment
this is what I’m calling:
local stars = DataStore2( "Igc", player )
stars:Increment( stars )
Edit:
The problem persists even if I require the module directly.
Did have a quick question, when adding new data to my save table. It would make that data nil obviously. But the only way to get around this is resetting the data store. Is there a method where I could possibly add new data without it being set tot nil?
I had a function for my old datastore like this:
function LoadNewData(Player)
local Default = blankData.ReturnBlankData()
for Key,Value in pairs(Default) do
if sessionData[Player.UserId][Key] == nil then
sessionData[Player.UserId][Key] = Value
end
end
end
Not sure if it’s good enough for this datastore though.
So, I’m adding a new table and using the GetTable method, but when I remove that table from the default data it still seems to be there. Anyway that I can get rid of it?
local function setupUserData()
local userData = {
Currency = {
["Money"] = 100000;
};
ownedPlacements = {};
plotPlacements = {};
}
return userData;
end
let’s assume that I add a new table, “testTable = {“test”};”
I join the game and loop the data and “test” is in it. But let’s remove that table from my default data table, whenever I rejoin the contents of that testTable will still be in there for some reason.
I didn’t say that wouldn’t work? but wouldn’t there be some automation with this if I had a large player-base and don’t wanna have to go to studio and make a table nil, then proceed to save the game and shutdown the entire game?
I suppose i’ll just add something to the datastore module.
Anything DataStore2 would provide would just be the same thing, so I’m not sure what could be introduced to help with this. If you used combined data stores (which you should be), I want to eventually introduce a way to clear a combined data store.