Does anyone know why this is throttling? if so, is it because there is a more efficient way to go about this datastore?

Also, sometimes it seems like random pieces of data dont get saved which would be really bad if someone was to lose their exp progress.

thank you for all responses.

--Variables
local leveldata = game:GetService("DataStoreService"):GetDataStore("level")
local EXPdata = game:GetService("DataStoreService"):GetDataStore("EXP")
local xpLeveldata = game:GetService("DataStoreService"):GetDataStore("xpLevel")
local Golddata = game:GetService("DataStoreService"):GetDataStore("Gold")
local toolsdata = game:GetService("DataStoreService"):GetDataStore("Tools")
local HttpService = game:GetService("HttpService")


--Data Storage Save
function savedata(dataname, playerid, value)
	game:GetService("DataStoreService"):GetDataStore(dataname):SetAsync(playerid, value)
end

--Leaderboard Variables
game.Players.PlayerAdded:connect(function(player)
	playerKey = "user."..player.userId	-- user key
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	--Gold
	local gold = Instance.new("IntValue")
	gold.Name = "Gold"
	gold.Value = Golddata:GetAsync(playerKey) or 0
	gold.Parent = leaderstats

	
	--Level
	local level = Instance.new("IntValue")
	level.Value = leveldata:GetAsync(playerKey) or 1
	level.Name = "Level"
	level.Parent = leaderstats

	
	--XP
	local EXP = Instance.new("IntValue")
	EXP.Value = EXPdata:GetAsync(playerKey) or 0
	EXP.Parent = player
	EXP.Name = "Exp"
	
	--XP Needed
	local xpLevel = Instance.new("IntValue")
	xpLevel.Value = xpLeveldata:GetAsync(playerKey) or 84
	xpLevel.Name = 'ExpNeeded'
	xpLevel.Parent = player
	
	--tools
	local tools = toolsdata:GetAsync(playerKey)
	if tools then
		for i,v in pairs(tools) do
			local tool = game.ReplicatedStorage.Tools:FindFirstChild(v)
			if tool then 
				tool:Clone().Parent = player.Backpack
				tool:Clone().Parent = player.StarterGear
				
			end
		end
	end		
end)

game.Players.PlayerRemoving:Connect(function(player) -- save player stats
	local toolsToSave = {}		
	for i,v in pairs(player.StarterGear:GetChildren()) do
		if v then
			table.insert(toolsToSave,v.Name)
		end
	end
	game:GetService("DataStoreService"):GetDataStore('Tools'):SetAsync(playerKey, toolsToSave)
	savedata('level',playerKey,player.leaderstats.Level.Value)
	savedata('EXP',playerKey,player.Exp.Value)
	savedata('xpLevel',playerKey,player.ExpNeeded.Value)
	savedata('Gold',playerKey,player.leaderstats.Gold.Value)
	print('data saved')
end)

1 comment

0

maybe the whole service has limits not only each datastore.