Hi all!
I’ve had some complaints this week about data not being saved in Datastore using Datastore2 by Krampframe, so I’m checking some numbers to see if there’s anything I can do to optimize the data flow.
Those are the numbers i get on the Developer Console about datastores, but I don’t know how to interpret them. Can anyone tell me what values would be expected, especially for Set & Store Async?
Also, What is the measurement this screen uses? milliseconds per task?
The specific problem I’ve been told is that a row added to a table is not saved, but the rest of the data (like gold, which is a float) is saved constantly and without problem. Note has only happened with some users, about 2% of all players of the game.
Thank you all
If I were to hazard a guess as to what is occurring then I’d say that you probably added in a new value to be saved in the table, but because the Get() method grabs the previous table that doesn’t have that value then there is no way to change and save your new value. Using the GetTable() method should remedy this problem.
Here is the code for the part that is causing troubles; its a function called by a event. The two data touched are Cash (a float, saving fine) and UpgradesTycoonComprados (a dictionary, causing problems for a few players).
When called, the function checks the cash; if enought, creates the object, and then creates a dictionary with all the objects for that player, and saves that dictionary
Sorry if the spanish references makes the reading hard; its my main lang xD
--invoca el SaveData2
DataStore2 = require(game.ServerStorage.MainModule)
DataStore2.Combine("******", "Cash")
DataStore2.Combine("******", "UpgradesTycoonComprados")
local EventoIntentaComprar = game.ReplicatedStorage.IntentaHacerCompra
function intenta(player, nombreBoton, cframeobj)
--general callings
local boton = game.ReplicatedStorage.Tycoon.Buttons:FindFirstChild(nombreBoton)
local coinStore = DataStore2("Cash", player)
local dineroPla = coinStore:Get(0)
if game.Workspace.Vientycoon:FindFirstChild(player.Team.Name):FindFirstChild("Tycoon_"..player.Name).Purchased:FindFirstChild(boton.Object.Value) == nil then
if tonumber(dineroPla) > tonumber(boton.Cost.Value - 1) then
--substracting money
dineroPla = dineroPla - boton.Cost.Value
--creating object server-side
local objeto = game.ReplicatedStorage.Tycoon.Purchases:FindFirstChild(boton.Object.Value):Clone()
objeto.Parent = game.Workspace.Vientycoon:FindFirstChild(player.Team.Name):FindFirstChild("Tycoon_"..player.Name).Purchased
objeto:SetPrimaryPartCFrame(cframeobj)
--saving all objects including the new one
local TodosLosObjComprados = {}
for i, v in pairs(game.Workspace.Vientycoon:FindFirstChild(player.Team.Name):FindFirstChild("Tycoon_" .. player.Name).Purchased:GetChildren()) do
if v.Name ~= "Part" then
TodosLosObjComprados[v.Name] = 1
end
end
local uStore = DataStore2("UpgradesTycoonComprados", player)
uStore:Set(TodosLosObjComprados)
uStore:SaveAsync()
--saving money
coinStore:Increment(-1*boton.Cost.Value)
end
end
end
EventoIntentaComprar.OnServerEvent:Connect(intenta)