Data Store Issues

Roblox Data Store

Over the months I have made several games on Roblox and are main issue has always been data store. Roblox data store limits are very limited and its hard storing a lot of data on bigger games. Is something going to be done about this? We have tried several methods like Data Store, Data Store2, Save Async and non of them seem to work that well.

It would be nice if Roblox done more tutorials since a lot of there stuff is outdated. Does anyone know a actual good way to store data? Its starting to get really tiring that we have tried so many ways and are still dealing with this issue.

2 Likes

What exactly are you storing in the datastores that its limiting up? I mean what exactly is the issue? There are alot of tutorials around devforum. I don’t think you’re understand what the problem is yourself, with the thing that you’re saying You’ve used DataStore, SaveAsync and stuff…

If you could give some error or warning you’re facing in console, it would good. Currently I can just say one thing that, if you handle the datastores properly there shouldn’t be any problems.

Big games don’t have DataStore problems AFAIK. Maybe the data that you are storing isn’t compressed enough or isn’t stored correctly? I don’t think you should blame Roblox on this, since the DataStore limit forces you to come up with better storing solutions, it’s a win win!

Well one of the issues are it sends way to many requests and says it needs to queue and causes data loss.

That is probably one of the most common issues that people face with datastores, although it has to be there otherwise there would be more load on Roblox Datastores. But I don’t get it, you said you’ve tried Datastore2, it won’t pass the limits as it saves only when Player leaves / Game Is Closing. Until and Unless you run the :Save() method manually, which isn’t intended.

And If you make your own data management system, you should only save during Player leave too.

That’s where DataStore2 come to play. You shouldn’t send frequent requests, rather cache the data first, then save it when the player leaves. You can also implement your own DataStore system to retry until you could save the data successfully.

Yes, we tired data store 2 twice now. Both times it takes a very long time for data to load and we are not sure why it exactly takes so long to load.

Are you require()-ing the module’s ID or you require()-ing the module itself? Since the last update of the module is a year ago, I think it’s safe to install the module directly in ServerScriptService and require()-ing it.

We are requiring it from the module.

There are many good ways to store data. Since you are having problems with DataStore/DataStore2/SaveAsync I can recommend a system that I use for all of my projects.

It’s called ProfileService and has always been reliable for my uses, and it may be with yours. It can save lots of data with ease, greatly configurable, and amazing at preventing duplication.

Good luck with finding a solution!

Okay ill check it out, Thanks.

I am not sure how Datastore2 is supposed to be causing that sort of problems, it would help if you could post your code for how you’re loading in / saving your data.

Sure, right now were not using Datatore2 but here you go.

local module = {}

local DataStoreService = game:GetService("DataStoreService")
local PlayerDataSave1 = DataStoreService:GetDataStore("1PlayerData_1")

local function AddStat(plr,status)
	for name,stat in pairs(status)do
		for num,sta in pairs(stat)do
			if name == "Hanging" then
				if num == "Upgrade" then
					plr:WaitForChild("Rebirth"):WaitForChild(num).Value = sta
				else
					plr:WaitForChild(num).Value = sta
				end
			else
				if name == "Upgrades" then
					plr[name][num].Value = sta.Val
					plr[name][num].amt.Value = sta.amt
				else
					plr[name][num].Value = sta
				end
			end
		end
	end
end

local function AddStat1(plr,status)
	for names,stat in pairs(status)do
		for num,tab in pairs(stat)do
			plr[names][tab.Name].Value = tab.Value
		end
	end
end

module.LoadData = function(player,data)
	local loaded
	loaded = pcall(function()
		if data then
			AddStat(player,data)
		else
			print("Not Data")
			local data2 = PlayerDataSave1:GetAsync(player.UserId.."_data")
			if data2 then
				AddStat1(player,data2)
			end
		end	
	end)

	if not loaded then
		warn("Data Not Loaded")
		for i,v in pairs(player:GetChildren()) do
			if v:IsA("Folder") or v:IsA("NumberValue") or v:IsA("IntValue") or v:IsA("StringValue") then
				v:Destroy()
			end
		end
		player:Kick("Data Loaded Incorrectly")
	else
		print(player.Name.." Loaded")
	end
end
module.PlayerAdded = function(player)
	local loaded
	loaded = pcall(function()
		if PlayerDataSave1:GetAsync(player.UserId) then
			local LocalData = game.ReplicatedStorage.GameClient.Events.RemoteFunction.LoadPlayerData:InvokeClient(player,PlayerDataSave1:GetAsync(player.UserId))
			module.LoadData(player,LocalData)
		else
			print("New Player")
		end	
	end)
	if not loaded then
		warn("Not Loaded")
		for i,v in pairs(player:GetChildren()) do
			if v:IsA("Folder") or v:IsA("NumberValue") or v:IsA("IntValue") or v:IsA("StringValue") then
				v:Destroy()
			end
		end
		player:Kick("Data Loaded Incorrectly")
	else
		print("Found")
	end
end

module.PlayerRemoving = function(player)

	local Data3 ={
		leaderstats = {};
		PlayerUpgradeFolder = {};
		Upgrades = {};
		Codes = {};
		Ranks = {};
		Island = {};
		GemShopFolder = {};
		Chests = {};
		Quest = {};
		Boost = {};
		Hanging = {};
	}

	for num,stat in pairs(player.leaderstats:GetChildren())do
		Data3.leaderstats[stat.Name] = stat.Value
	end
	for num,stat in pairs(player.PlayerUpgradeFolder:GetChildren())do
		Data3.PlayerUpgradeFolder[stat.Name] = stat.Value
	end
	for num,stat in pairs(player.Upgrades:GetChildren())do
		Data3.Upgrades[stat.Name] = {
			Val = stat.Value,
			amt = stat.amt.Value
		}
	end
	for num,stat in pairs(player.Codes:GetChildren())do
		Data3.Codes[stat.Name] = stat.Value
	end
	for num,stat in pairs(player.Ranks:GetChildren())do
		Data3.Ranks[stat.Name] = stat.Value
	end
	for num,stat in pairs(player.Island:GetChildren())do
		Data3.Island[stat.Name] = stat.Value
	end
	for num,stat in pairs(player.GemShopFolder:GetChildren())do
		Data3.GemShopFolder[stat.Name] = stat.Value
	end
	for num,stat in pairs(player.Chests:GetChildren())do
		Data3.Chests[stat.Name] = stat.Value
	end
	for num,stat in pairs(player.Quest:GetChildren())do
		Data3.Quest[stat.Name] = stat.Value
	end
	for num,stat in pairs(player.Boost:GetChildren())do
		Data3.Boost[stat.Name] = stat.Value
	end
	Data3.Hanging[player.Rebirth.Upgrade.Name]= player.Rebirth.Upgrade.Value
	Data3.Hanging[player.RankEquip.Name]= player.RankEquip.Value
	Data3.Hanging[player.MiniGame.Name]= player.MiniGame.Value
	Data3.Hanging[player.BossDead.Name]= player.BossDead.Value
	Data3.Hanging[player.Tokens.Name]= player.Tokens.Value
	Data3.Hanging[player.BattlePass.Name]= player.BattlePass.Value
	Data3.Hanging[player.BoostInc.Name]= player.BoostInc.Value

	local saved
	saved = pcall(function()
		PlayerDataSave1:SetAsync(player.UserId,Data3)
	end)
	if not saved then
		warn(player.Name.." Data Lost")
	else
		print("Data Saved")
	end
end

return module