302: SetAsync request dropped. Request was throttled, but throttled request queue was full

script:

local DataStore = game:GetService("DataStoreService")
local Level1 = DataStore:GetDataStore("Levels_Test1")
local Beli11 = DataStore:GetDataStore("Beli_Test1")
local Exp1 = DataStore:GetDataStore("Exp_Test1")
local ExpNeed1 = DataStore:GetDataStore("ExpNeed_Test1")
local DefenseP1 = DataStore:GetDataStore("DefenseP_Test1")
local SwordP1 = DataStore:GetDataStore("SwordP_Test1")
local LuckP1 = DataStore:GetDataStore("LuckP_Test1")
local AbilityP1 = DataStore:GetDataStore("AbilityP_Test1")
local Defense1 = DataStore:GetDataStore("Defense_Test1")
local Sword1 = DataStore:GetDataStore("Sword_Test1")
local Luck1 = DataStore:GetDataStore("Luck_Test1")
local Ability1 = DataStore:GetDataStore("Ability_Test1")
local Combat1 = DataStore:GetDataStore("Combat_Test1")
local Stamina1 = DataStore:GetDataStore("Stamina_Test1")
local Points1 = DataStore:GetDataStore("Points_Test1")
local StaminaP1 = DataStore:GetDataStore("StaminaP_Test1")
local CombatP1 = DataStore:GetDataStore("CombatP_Test1")

game.Players.PlayerAdded:Connect(function(Plr)
	local stats = Instance.new("Folder", Plr)
	stats.Name = "Data"
	--- Level System
	local Levels = Instance.new("IntValue", stats)
	Levels.Name = "Levels"
	Levels.Value = 1
	local Exp = Instance.new("IntValue", stats)
	Exp.Name = "Exp"
	Exp.Value = 0
	local ExpNeed = Instance.new("IntValue", stats)
	ExpNeed.Name = "ExpNeed"
	ExpNeed.Value = 200
	--- Money System
	local Beli = Instance.new("IntValue", stats)
	Beli.Name = "Gold"
	Beli.Value = 0
	--- Stats Text
	local DefenseP = Instance.new("IntValue", stats)
	DefenseP.Name = "DefenseP"
	DefenseP.Value = 1
	local SwordP = Instance.new("IntValue", stats)
	SwordP.Name = "SwordP"
	SwordP.Value = 1
	local LuckP = Instance.new("IntValue", stats)
	LuckP.Name = "LuckP"
	LuckP.Value = 1
	local AbilityP = Instance.new("IntValue", stats)
	AbilityP.Name = "AbilityP"
	AbilityP.Value = 1
	local CombatP = Instance.new("IntValue", stats)
	CombatP.Name = "CombatP"
	CombatP.Value = 1
	local StaminaP = Instance.new("IntValue", stats)
	StaminaP.Name = "StaminaP"
	StaminaP.Value = 1
	--- Stats System
	local Points = Instance.new("IntValue", stats)
	Points.Name = "Points"
	Points.Value = 0
	local PointsS = Instance.new("IntValue", stats)
	PointsS.Name = "PointsS"
	PointsS.Value = 1
	local Defense = Instance.new("IntValue", stats)
	Defense.Name = "Defense"
	Defense.Value = 0
	local Sword = Instance.new("IntValue", stats)
	Sword.Name = "Sword"
	Sword.Value = 0
	local Luck = Instance.new("IntValue", stats)
	Luck.Name = "Luck"
	Luck.Value = 0
	local Ability = Instance.new("IntValue", stats)
	Ability.Name = "Ability"
	Ability.Value = 0
	local Defense = Instance.new("IntValue", stats)
	Defense.Name = "Defense"
	Defense.Value = 0
	local Combat = Instance.new("IntValue", stats)
	Combat.Name = "Combat"
	Combat.Value = 0
	local Stamina = Instance.new("IntValue", stats)
	Stamina.Name = "Stamina"
	Stamina.Value = 0
---- Datastore ----
--- Levels
   Levels.Value = Level1:GetAsync(Plr.UserId) or Levels.Value
	   Level1:SetAsync(Plr.UserId, Levels.Value)
      Levels.Changed:connect(function()
	   Level1:SetAsync(Plr.UserId, Levels.Value)
   end)
--- Gold
   Beli.Value = Beli11:GetAsync(Plr.UserId) or Beli.Value
	   Beli11:SetAsync(Plr.UserId, Beli.Value)
      Beli.Changed:connect(function()
	   Beli11:SetAsync(Plr.UserId, Beli.Value)
   end)
--- Exp
   Exp.Value = Exp1:GetAsync(Plr.UserId) or Exp.Value
	   Exp1:SetAsync(Plr.UserId, Exp.Value)
      Exp.Changed:connect(function()
	   Exp1:SetAsync(Plr.UserId, Exp.Value)
   end)
--- ExpNeed
   ExpNeed.Value = ExpNeed1:GetAsync(Plr.UserId) or ExpNeed.Value
	   ExpNeed1:SetAsync(Plr.UserId, ExpNeed.Value)
      ExpNeed.Changed:connect(function()
	   ExpNeed1:SetAsync(Plr.UserId, ExpNeed.Value)
   end)
--- SwordP
   SwordP.Value = SwordP1:GetAsync(Plr.UserId) or SwordP.Value
	   SwordP1:SetAsync(Plr.UserId, SwordP.Value)
      SwordP.Changed:connect(function()
	   SwordP1:SetAsync(Plr.UserId, SwordP.Value)
	end)
--- CombatP
	CombatP.Value = CombatP1:GetAsync(Plr.UserId) or CombatP.Value
	CombatP1:SetAsync(Plr.UserId, CombatP.Value)
	CombatP.Changed:connect(function()
		CombatP1:SetAsync(Plr.UserId, CombatP.Value)
	end)
--- StaminaP
	StaminaP.Value = StaminaP1:GetAsync(Plr.UserId) or StaminaP.Value
	StaminaP1:SetAsync(Plr.UserId, StaminaP.Value)
	StaminaP.Changed:connect(function()
		StaminaP1:SetAsync(Plr.UserId, StaminaP.Value)
	end)
	
--- DefenseP
   DefenseP.Value = DefenseP1:GetAsync(Plr.UserId) or DefenseP.Value
	   DefenseP1:SetAsync(Plr.UserId, DefenseP.Value)
      DefenseP.Changed:connect(function()
	   DefenseP1:SetAsync(Plr.UserId, DefenseP.Value)
   end)
--- LuckP
   ExpNeed.Value = ExpNeed1:GetAsync(Plr.UserId) or ExpNeed.Value
	   ExpNeed1:SetAsync(Plr.UserId, ExpNeed.Value)
      ExpNeed.Changed:connect(function()
	   ExpNeed1:SetAsync(Plr.UserId, ExpNeed.Value)
   end)
--- SpecialP
   ExpNeed.Value = ExpNeed1:GetAsync(Plr.UserId) or ExpNeed.Value
	   ExpNeed1:SetAsync(Plr.UserId, ExpNeed.Value)
      ExpNeed.Changed:connect(function()
	   ExpNeed1:SetAsync(Plr.UserId, ExpNeed.Value)
   end)
--- Sword
   Sword.Value = Sword1:GetAsync(Plr.UserId) or Sword.Value
	   Sword1:SetAsync(Plr.UserId, SwordP.Value)
      Sword.Changed:connect(function()
	   Sword1:SetAsync(Plr.UserId, SwordP.Value)
   end)
--- Defense
   Defense.Value = Defense1:GetAsync(Plr.UserId) or Defense.Value
	   Defense1:SetAsync(Plr.UserId, Defense.Value)
      Defense.Changed:connect(function()
	   Defense1:SetAsync(Plr.UserId, Defense.Value)
	end)
	--- Combat
	Combat.Value = Combat1:GetAsync(Plr.UserId) or Combat.Value
	Combat1:SetAsync(Plr.UserId, Combat.Value)
	Combat.Changed:connect(function()
		Combat1:SetAsync(Plr.UserId, Combat.Value)
   end)
--- Stamina
	Stamina.Value = Stamina1:GetAsync(Plr.UserId) or Stamina.Value
	Stamina1:SetAsync(Plr.UserId, Stamina.Value)
	Stamina.Changed:connect(function()
		Stamina1:SetAsync(Plr.UserId, Stamina.Value)
   end)
--- Luck
   Luck.Value = Luck1:GetAsync(Plr.UserId) or Luck.Value
	   Luck1:SetAsync(Plr.UserId, Luck.Value)
      Luck.Changed:connect(function()
	   Luck1:SetAsync(Plr.UserId, Luck.Value)
   end)
--- Special
	Ability.Value = Ability1:GetAsync(Plr.UserId) or Ability.Value
	Ability1:SetAsync(Plr.UserId, Ability.Value)
	Ability.Changed:connect(function()
	Ability1:SetAsync(Plr.UserId, Ability.Value)
   end)
--- Points
   Points.Value = Points1:GetAsync(Plr.UserId) or Points.Value
	   Points1:SetAsync(Plr.UserId, Points.Value)
      Points.Changed:connect(function()
	   Points1:SetAsync(Plr.UserId, Points.Value)
   end)
end)

game.Players.PlayerAdded:Connect(function(plr)
	wait(.1)
	local Exp = plr.Data.Exp
	local Levels = plr.Data.Levels
	local ExpNeed = plr.Data.ExpNeed
	local Points = plr.Data.Points
	
	while wait() do
		if Exp.Value >= (100 * (Levels.Value + 1)) and Levels.Value <= 399 then
			Levels.Value = Levels.Value + 1
			Points.Value = Points.Value + 3
			Exp.Value = Exp.Value - ExpNeed.Value
			ExpNeed.Value = ExpNeed.Value + 100
			game.ReplicatedStorage.LevelSystem.LevelUpGui:FireClient(plr)
		end
	end
end)

game.Players.PlayerRemoving:connect(function(Player)
	Level1:SetAsync(Player.UserId, Player.Data.Levels.Value)
	Beli11:SetAsync(Player.UserId, Player.Data.Beli.Value)
	Exp1:SetAsync(Player.UserId, Player.Data.Exp.Value)
	ExpNeed1:SetAsync(Player.UserId, Player.Data.ExpNeed.Value)
	SwordP1:SetAsync(Player.UserId, Player.Data.SwordP.Value)
	DefenseP1:SetAsync(Player.UserId, Player.Data.DefenseP.Value)
	LuckP1:SetAsync(Player.UserId, Player.Data.LuckP.Value)
	AbilityP1:SetAsync(Player.UserId, Player.Data.AbilityP.Value)
	CombatP1:SetAsync(Player.UserId, Player.Data.CombatP.Value)
	StaminaP1:SetAsync(Player.UserId, Player.Data.StaminaP.Value)
	Sword1:SetAsync(Player.UserId, Player.Data.Sword.Value)
	Defense1:SetAsync(Player.UserId, Player.Data.Defense.Value)
	Luck1:SetAsync(Player.UserId, Player.Data.Luck.Value)
	Ability1:SetAsync(Player.UserId, Player.Data.Ability.Value)
	Combat1:SetAsync(Player.UserId, Player.Data.Combat.Value)
	Stamina1:SetAsync(Player.UserId, Player.Data.Stamina.Value)
	Points1:SetAsync(Player.UserId, Player.Data.Points.Value)
end)

I don’t know what’s the problem, but I think I’m getting my points too quickly

Output:

302: SetAsync request dropped. Request was throttled, but throttled request queue was full.
1 Like

Oh damn… that’s a lot of DataStores and connections. You could honestly just make a table (or a module) for that so you wouldn’t have so many requests to make… it’s a good idea.

2 Likes

You should not make a separate datastore for every stat. Instead, store the player data as a table with all those fields, for example

local DataStore = game:GetService("DataStoreService")
local PlayerData = DataStore:GetDataStore("PlayerData")

game.Players.PlayerAdded:Connect(function(Plr)
    --...
    local data = PlayerData:GetAsync(Plr.UserId)
    Levels.Value = data.Level1 or Levels.Value
    --...
end)

game.Players.PlayerRemoving:Connect(function(Player)
    local data = {}
    for i,v in pairs(Player.Data:GetChildren()) do
        data[v.Name] = v.Value
    end
    PlayerData:SetAsync(Player.UserId, data)
end)

etc.

You might also want to implement a better system than listening to Changed of every leaderstat value. Ideally you should make the data handling independent of its displaying - do not use leaderstats as a source of data, only use it to display it.

1 Like

I admit that I did not understand very well …