Hey guys, I’m having a few problems with my Datastore2 data integrity even though I am literally just using the increment command to add or subtract values. Sadly, my small group of testers are occasionally complaining their win or gold has sometimes gone missing, even though I thought Datastore2 was supposed to be bulletproof.
Anyway, what I want to do is dump out the data for each player at the end of each testing cycle, so I can verify the data is or isn’t missing.
So is there anyway I can iterate through the whole datastore2 (for my game) to collect player data (approx 40 players)?
I’m thinking the Players Service is only for the current game and I wanted to gather this data while the players are offline.
I do have the testers in a ROBLOX group so is it possible to get keys from the group and then iterate through the datastore2?
Sorry, I’m still a noob at this coding stuff, so i have no code to share, but I have a hunch this might be possible.
So any advice or examples on how you have done this in the past would be invaluable.
Before you switch to default data storage, it may be worth asking in the DS2 thread because @Kampfkarren is active answering questions. I know that DS2 works well because I and many other people have had no other problems with it. It is most likely something very simple that has been over looked. Good luck
DataStore2 is practically ‘bulletproof’, if you use it correctly. I use it in my game, and have gotten absolutely zero reports of any sort of data loss. During development, the only time data loss occurred was at the fault of my scripting, not the module. Double-check your scripts and make sure they all work properly – sometimes faults can be hard to look for so you’ll need to do a lot of debugging. Especially since you say you’re a ‘noob at this coding stuff’, it is most likely a problem in your data saving scripts.
There is a way to use a datastore editing plugin to view player data, which has already been discussed in the DataStore2 thread, which could help you for what you are trying to achieve.
This isn’t possible with default data stores, so it isn’t possible with DataStore2.
Data loss is going to be inevitable as a result of DataStore2 being built on Roblox data store servers, which go down somewhat frequently – the default settings just minimize it as much as possible. If you are getting data loss, it is either because of data store servers going down or more likely your code is not correct.
Ha my data saving script literally looks like this.
local goldStore = DataStore2("Gold", plr)
goldStore:Increment(150) -- Give them 150 gold
I was lead to believe this is all i needed to update the data.
But not sure if i need onupdate functions like normal datastores. Anyway it has been working just worried that people complain about errors based on such a small test group. (And it’s always people lost the last win or some god etc.) Never it didn’t add the value to there score)
TBH: I suspect the problem is around the shutting down of servers at the end of the day. Perhaps I need to look into this more.
You said you’re shutting down servers? One time I did have a problem with DataStore2 because I was shutting down servers, and that led to data loss. Make sure you have the most up to date version of DataStore2; that’s what fixed it for me. I was using an old version that didn’t have anything in place in the event of a server shut down.
Ok thank-you for your reply and this awesome module. I just want to follow best practices
This is my datacontroller script
local DataStore2 = require(1936396537)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
DataStore2.Combine("MasterKey2", "Gold", "Gems", "Wins")
game.Players.PlayerAdded:Connect(function(player)
local goldStore = DataStore2("Gold",player)
local gemsStore = DataStore2("Gems",player)
local winsStore = DataStore2("Wins",player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local Gold = Instance.new("IntValue", leaderstats)
Gold.Name = "Gold"
Gold.Value = goldStore:Get(0)
Gold.Parent = leaderstats
local Gems = Instance.new("IntValue", leaderstats)
Gems.Name = "Gems"
Gems.Value = gemsStore:Get(0)
Gems.Parent = leaderstats
local Wins = Instance.new("IntValue", leaderstats)
Wins.Name = "Wins"
Wins.Value = winsStore:Get(0)
Wins.Parent = leaderstats
goldStore:OnUpdate(function(newPoints)
-- This function runs every time the value inside the data store changes.
Gold.Value = newPoints
end)
gemsStore:OnUpdate(function(newPoints)
-- This function runs every time the value inside the data store changes.
Gems.Value = newPoints
end)
winsStore:OnUpdate(function(newPoints)
-- This function runs every time the value inside the data store changes.
Wins.Value = newPoints
end)
leaderstats.Parent = player
end)
That’s your problem right there. That’s exactly what I was doing and it caused problems. Get the newest version from the Github and put it directly into your game, don’t require from the asset. It’s not up to date.
Ok, well that makes sense. And now i have learned how to import a model into ROBLOX.
So i assume this is what i replace the existing require code with?
local ServerScriptService = game:GetService("ServerScriptService")
local DataStore2 = require(ServerScriptService.DataStore2)
And I see the server close thing was a bug so hopefully that’s all my problem is now.
Yes, that’s what you want to do. I didn’t read your code so I can’t guarantee that you still don’t have any problems there, but assuming you don’t have any problems there you should’ve just fixed it.