How bout if you’re dealing with teleportation. That’s where saving issues are the biggest problem.
Zombie Strike just saves everyone’s data before they teleport off, works perfectly fine for us.
so the good way its calling a save() before teleporting to another place?
Yeah I guess so, however it might call that twice since the player ALSO leaves? I would go for it, if I were you. It probably shoudn’t throttle with the same key warning if you’re using the OrderedBackups method.
The Current DataStore2 script, unedited, removes functionality of Soft Shutdown scripts.
I’ve looked into the Code and it sets the player parent to nil, so .AncestryChanged gets fired.
The problem with that is, Guis get destroyed, Player can’t be selected. I had to remove that line.
This might be another reason to discourage OrderedBackups.
Ow.
This is also causing sometimes players to get stuck in place for a long time without a Rejoin button.
Saving twice in a row won’t throttle because the 2nd save won’t have any new data–it won’t actually perform a real save.
Still having reports of data loss. The money is in an Int that never gives problems, but the tycoon objects are in a table that fails a lot. There is a save() on buying a tycoon object, and a AfterSave that removes the “wait” gui. The gui is removed so the table should be saved.
The save() was added because of data loss.
That’s pretty bad
Are you combining datastores btw? It might be some form of throttling.
Thankfully if you’re using the OrderedBackups method you should be able to get the past saves.
I’m combining datastores on every script yes, also using OrderedBackups method
Would I combine any keys before or after defining the datastores? For example:
Would I do
local DataStore2 = require(1936396537)
game.Players.PlayerAdded:Connect(function(player)
local cashDataStore = DataStore2("cash", player)
local bankDataStore = DataStore2("bank", player)
DataStore2.Combine("master", "cash", "bank")
end
or
local DataStore2 = require(1936396537)
game.Players.PlayerAdded:Connect(function(player)
DataStore2.Combine("master", "cash", "bank")
local cashDataStore = DataStore2("cash", player)
local bankDataStore = DataStore2("bank", player)
end
? Any help is appreciated!
(Sorry for the previous bad code)
local Datastore2 = require() -- USE the DateStore2 Module, requiring the Id is outdated
Datastore2.Combine("MainKey","Cash","Bank")
game:GetService("Players").PlayerAdded:Connect(function(player)
local cashDataStore = Datastore2("Cash", player)
local bankDataStore = Datastore2("Bank", player)
end)
@SnowyStxrm Please don’t require the module Id since that is very outdated. You can get the up-to-date version here. I would require it before the playerAdded Event, like I have shown in the code above. Hope this helps.
You combine it even before the player joins. You should only combine once.
local DataStore2 = require(script.DataStore2)
DataStore2.Combine("Data", "A", "B", "C")
game.Players.PlayerAdded:Connect(function(player)
local A = DataStore2("A", player)
local B = DataStore2("B", player)
local C = DataStore2("C", player)
A:SetBackup(3)
B:SetBackup(3)
C:SetBackup(3) -- Is this redundant?
local AValue = A:Get(100)
local BValue = B:Get(50)
local CValue = C:Get(0)
local ABackedUp = A:IsBackup()
local BBackedUp = B:IsBackup()
local CBackedUp = C:IsBackup() -- Is this redundant?
end
If for some reason A fails and C succeeds, there will exist a duplication glitch. Would this ever happen? And if so is there a built in way I could prevent it from happening and still be able to call :Increment() on the dataStores?
I want if A fails and becomes a backup, C becomes a backup too.
I’m pretty sure you don’t need to use :IsBackup() for all ‘datastores’. They’re combined, so they should end up in the same thing.
:IsBackup()
should be used as an argument to decide on something.
It will return you true or false, if it is a backup or not.
if A:IsBackup() then
print("Data is backup!")
end
They’re all combined under one data store, so it’s impossible for one to be a backup and for others not to be.
I’ve made this simple script so I can use DataStore2 easily and it’s really amazing how DataStore2 is so flexible that anyone can create amazing stuff with it easily and makes the data saving safe.
You just need to edit the keysData Table
local keysData = {
{"money",
"leaderstats",
"Cash",
"IntValue",
100
},
{"gems",
"leaderstats",
"Gems",
"IntValue",
5
},
{"lifes", -- Key
"stats", -- Value's Parent's Name
"Lifes", -- Value's Name
"DoubleConstrainedValue", -- Value's Class Name
3, -- Value
0, -- Min Value
3 -- Max Value (Only used when the Value's Class Name is DoubleConstrainedValue)
}
}
The Value’s Parents will be auto created if can’t be found under Players>Player
I can’t thank you enough for making this! <3
It’s super helpful and prevented me from going insane after tuns of dataloss