How to use DataStore2 - Data Store caching and data loss prevention

How feasible is it to use two different DS2 modules to migrate to standard saving method over time? Could I just check if they have data in the new standard method store, then if not check the ordered backups? Also disable the saving for the ordered backups store. Would this cripple a server with 20+ people?

I don’t see any reason why that wouldn’t work, so it’s worth a shot.

1 Like

Do I need a set up a way to disconnect the OnUpdate() events that I have connected on my PlayerAdded function? Or does Datastore2 handle this when the player leaves?

I got a Error from today [wasn’t editing or making anything relate scripts to DataStore2]
22:50:38.701 - 502: API Services rejected request with error. HTTP 503 (Service Unavailable)

22:50:38.703 - Stack Begin

22:50:38.705 - Script ‘ServerScriptService.DataStore2.SavingMethods.OrderedBackups’, Line 28

22:50:38.706 - Script ‘ServerScriptService.DataStore2.Promise’, Line 218

22:50:38.707 - Stack End

2 Likes

My stats are saving fine when a player leaves, but when there is a server shutdown or crash, it doesn’t save at all and just reverts to where it was before the player played for that session.
Here is the part of the script where I save:

loadData(money, moneyData, defaultMoney)	
    	loadData(wins, winsData, defaultKD)	
    	
    	local function changedValue(Item, Data)
    		Data:Set(Item.Value)
    	end
    	
    	money.Changed:Connect(function()
    		changedValue(money, moneyData)
    	end)
    	wins.Changed:Connect(function()
    		changedValue(wins, winsData)
    	end)

I tried using BindToClose earlier, but it didn’t do anything.

EDIT: it seems that i have forgotten to turn on API services. Sorry for any troble caused.

Also have this error.

Also getting a warn “Data store [key] was not saved as it was not updated”

For some reason this error is prevalent in all of my game servers that are reported broken.

That just means data stores are down.

That means you are not calling :Set or similar methods. The warning is pretty clear.

Are you on the latest version from GitHub?

Yes, I am using require(1936396537) to get the module

I am calling :Set , this issue arose about a day ago.

I’m getting the error static2240 is reporting, followed by the warning that the data store was not saved.

I’ve made no changes/modifications that could affect this, and it’s been working perfect for 5 months. Just yesterday I’ve been getting reports from players that the game is experiencing broken servers.

For every server I check that is broken, I am receiving the HTTP 503 (Service Unavailable) error, followed by a warning that Datastores are not updating.

1 Like

That isn’t the latest release. The free model is not updated anymore, and hasn’t been recommended in a long time. Please recheck the documentation.

Have you turned on API services? I had the same error, just forgot to turn it on.

Thanks for the reply!

Yes, I do have API services turned on. I am noticing that sometimes there are too many requests added to queue, but I am not sure what I’m doing to do that. Typically these warnings arise, followed by the HTTP 503 error, and then the Datastore failing to update.

I’m using :Set whenever data changes, but from what I read, this shouldn’t be the cause.

I’m using :Get() to get values and :Set() to change them.

Apologies for my potential lack of knowledge regarding DS2, but this issue really came out of no where and I’m stumped!

I am also getting errors of “503 Service Unavailable” for DataStore… and I don’t use DataStore2. Problems started happening about 1 day ago for no apparent reason. (My bad if I shouldn’t be posting this here). It also seems that the DataStore queue overfills too fast. It’s really odd.

I am also getting this error regarding "502: API Services rejected request with error HTTP 503 (service unavailable) causing user’s data to be wiped, I do not use DataStore2.

I made a separate thread here regarding HTTP 503 errors. This seems like an issue prevalent with both DS2 and non-DS2 users. Please post your experiences there if possible:

1 Like

hello, I have been working for a long time using the DataStore2 system, I basically already know how to use it, but lately a script of my “Quest” is not working before, it used to work normally …
it seems that for some reason it is not reading the increment part in the script, I can get the value of: Get () but I can’t change a value in the script using: Increment () and: Set ()

this is my script [Server Script] (It can be a bit confusing but I hope you can understand)

local DataStore2 = require(5159892169) --This is my module OBS: (Updated Version!)
local ConverValues = require(5084840082)

DataStore2.Combine("GameData_V1","Power","TotalPower","Rebirth")

local localplayer = script.Parent.Parent.Parent.Parent

--Remotes--
local Remote = script.RemoteEvent
local KilledDummy = game.ReplicatedStorage.Events.Giver_Event
local UpdatedPowerEvent = game.ReplicatedStorage.Events.Update_UIPower
local CompletedQuestEvent = game.ReplicatedStorage.Events.QuestCompletedEventGive
---------------

local QuestFrame = script.Parent.Parent.QuestFrame

local Kills = nil
local NumberKills = nil
local QuestDummy = nil
local DummyNameInQuest = nil
local GiverAmountPower = nil

local HaveQuest = false

Remote.OnServerEvent:Connect(function(player,DummyName,DummyNameQuest,ToKills,ValueToGive)
if player.Name == localplayer.Name then
local RebirthSave  = DataStore2("Rebirth",game.Players[player.Name])
QuestFrame:TweenPosition(UDim2.fromScale(1,0.95),'Out', 'Bounce', 1,true)
HaveQuest = true
GiverAmountPower = (tonumber(ValueToGive)*(RebirthSave:Get(0)+1))
QuestDummy = DummyName
DummyNameInQuest = DummyNameQuest
Kills = 0
NumberKills = ToKills
local TextQuest = "Kill "..ToKills.." "..DummyNameQuest.." to earn "..ConverValues:ConvertShort(GiverAmountPower)
QuestFrame.QuestInfo.Text = TextQuest
QuestFrame.QuestKills.Kill_Amount.Text = Kills.."/"..ToKills
QuestFrame.QuestKills.QuestBar.Size = UDim2.fromScale(0,1)
end
end)

function QuestFinished()
local random = math.random(250, 750)
local xnew = random / 1000
local new = script:WaitForChild("PowerGived"):Clone()
new.Text = "💪+".. ConverValues:ConvertShort(GiverAmountPower)
new.Position = UDim2.new(xnew, 0, 1, 0)
new.Parent = script.Parent.Parent
new:TweenPosition(UDim2.new(new.Position.X,0,0,0),'Out', 'Linear', 1)
QuestFrame:TweenPosition(UDim2.fromScale(1,1.95),'Out', 'Bounce', 1,true)
HaveQuest = false
GiverAmountPower = nil
QuestDummy = nil
DummyNameInQuest = nil
Kills = nil
NumberKills = nil
wait(4)
new:Destroy()
end

local function FinishQuest()
QuestFrame:TweenPosition(UDim2.fromScale(1,1.95),'Out', 'Bounce', 1,true)
wait()
HaveQuest = false
GiverAmountPower = nil
QuestDummy = nil
DummyNameInQuest = nil
Kills = nil
NumberKills = nil
end

script.FinishQuest.OnServerEvent:Connect(FinishQuest)

KilledDummy.Event:Connect(function(PlayerName,DummyKilledName)
if HaveQuest then
if PlayerName == localplayer.Name then
	if DummyKilledName == QuestDummy then
		Kills = Kills+1
		local TextQuest = "Kill "..NumberKills.." "..DummyNameInQuest.." to earn "..ConverValues:ConvertShort(GiverAmountPower)
		QuestFrame.QuestInfo.Text = TextQuest
		QuestFrame.QuestKills.Kill_Amount.Text = Kills.."/"..NumberKills
		local BarSize = Kills/NumberKills
		QuestFrame.QuestKills.QuestBar:TweenSize(UDim2.fromScale(BarSize,1),'In', 'Quint', 0.5, true)
		if Kills == NumberKills then
			local PowerSave  = DataStore2("Power",game.Players[PlayerName])
			local TotalPowerSave  = DataStore2("TotalPower",game.Players[PlayerName])
			PowerSave:Increment(GiverAmountPower,0) -- For some reason these lines are not being executed by datastore2
			TotalPowerSave:Increment(GiverAmountPower,0) -- For some reason these lines are not being executed by datastore2
			QuestFinished()
		end
	end
end
end
end)

this post has the ceritificate of awesome