Hey developers!
The script I have made suddenly started to display an error, “SetAsync Request Dropped. Request was throttled, but throttled request queue was full” and has been making the game lag. Is there any way to fix this issue? Any help is appreciated!
local startamount = 0
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("LeaderStatSave")
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local Cash = Instance.new("IntValue",leader)
Cash.Name = "Tokens"
local monsterskins = Instance.new("Folder",player)
monsterskins.Name = "monsterskins"
local houseskins = Instance.new("Folder",player)
houseskins.Name = "houseskins"
--------------------------MONSTERS---------------------------
local AllEyesTom = Instance.new("NumberValue",monsterskins)
AllEyesTom.Name = "AllEyesTomValue"
local Skeletom = Instance.new("NumberValue",monsterskins)
Skeletom.Name = "SkeletomValue"
local ForsakenTom = Instance.new("NumberValue",monsterskins)
ForsakenTom.Name = "ForsakenTomValue"
local JackOTom = Instance.new("NumberValue",monsterskins)
JackOTom.Name = "JackOTomValue"
local WhiteoutBob = Instance.new("NumberValue",monsterskins)
WhiteoutBob.Name = "WhiteoutBobValue"
local MadhatterBob = Instance.new("NumberValue",monsterskins)
MadhatterBob.Name = "MadhatterBobValue"
local ForsakenBob = Instance.new("NumberValue",monsterskins)
ForsakenBob.Name = "ForsakenBobValue"
local FrankenBob = Instance.new("NumberValue",monsterskins)
FrankenBob.Name = "FrankenBobValue"
--------------------------HOUSES-----------------------------
local Asylum = Instance.new("NumberValue",houseskins)
Asylum.Name = "AsylumValue"
local Blue = Instance.new("NumberValue",houseskins)
Blue.Name = "BlueValue"
local Cabin = Instance.new("NumberValue",houseskins)
Cabin.Name = "CabinValue"
local Diamond = Instance.new("NumberValue",houseskins)
Diamond.Name = "DiamondValue"
local Infection = Instance.new("NumberValue",houseskins)
Infection.Name = "InfectionValue"
local PurpleCrown = Instance.new("NumberValue",houseskins)
PurpleCrown.Name = "PurpleCrownValue"
local Red = Instance.new("NumberValue",houseskins)
Red.Name = "RedValue"
local Trophy = Instance.new("NumberValue",houseskins)
Trophy.Name = "TrophyValue"
local Robux = Instance.new("NumberValue",houseskins)
Robux.Name = "RobuxValue"
local GhostsPumpkinsBats = Instance.new("NumberValue",houseskins)
GhostsPumpkinsBats.Name = "GhostsPumpkinsBatsValue"
local playerid = "Player_" .. player.UserId
local data = ds:GetAsync(playerid)
if data then
Cash.Value = data['Tokens']
---------------------MONSTERS----------------------
AllEyesTom.Value = data['AllEyesTomValue']
Skeletom.Value = data['SkeletomValue']
ForsakenTom.Value = data['ForsakenTomValue']
JackOTom.Value = data['JackOTomValue']
WhiteoutBob.Value = data['WhiteoutBobValue']
MadhatterBob.Value = data['MadhatterBobValue']
ForsakenBob.Value = data['ForsakenBobValue']
FrankenBob.Value = data['FrankenBobValue']
--------------------HOUSES-------------------------
Asylum.Value = data['AsylumValue']
Blue.Value = data['BlueValue']
Cabin.Value = data['CabinValue']
Diamond.Value = data['DiamondValue']
Infection.Value = data['InfectionValue']
PurpleCrown.Value = data['PurpleCrownValue']
Red.Value = data['RedValue']
Trophy.Value = data['TrophyValue']
Robux.Value = data['RobuxValue']
GhostsPumpkinsBats.Value = data['GhostsPumpkinsBatsValue']
else
Cash.Value = 0
-----MONSTERS-----
AllEyesTom.Value = 0
Skeletom.Value = 0
ForsakenTom.Value = 0
JackOTom.Value = 0
WhiteoutBob.Value = 0
MadhatterBob.Value = 0
ForsakenBob.Value = 0
FrankenBob.Value = 0
-----HOUSES-------
Asylum.Value = 0
Blue.Value = 0
Cabin.Value = 0
Diamond.Value = 0
Infection.Value = 0
PurpleCrown.Value = 0
Red.Value = 0
Trophy.Value = 0
Robux.Value = 0
GhostsPumpkinsBats.Value = 0
end
game.Players.PlayerRemoving:connect(function(player)
local datatosave = {
Tokens = player.leaderstats.Tokens.Value;
--------------------------MONSTERS---------------------------
AllEyesTomValue = player.monsterskins.AllEyesTomValue.Value;
SkeletomValue = player.monsterskins.SkeletomValue.Value;
ForsakenTomValue = player.monsterskins.ForsakenTomValue.Value;
JackOTomValue = player.monsterskins.JackOTomValue.Value;
WhiteoutBobValue = player.monsterskins.WhiteoutBobValue.Value;
MadhatterBobValue = player.monsterskins.MadhatterBobValue.Value;
ForsakenBobValue = player.monsterskins.ForsakenBobValue.Value;
FrankenBobValue = player.monsterskins.FrankenBobValue.Value;
--------------------------HOUSES-----------------------------
AsylumValue = player.houseskins.AsylumValue.Value;
BlueValue = player.houseskins.BlueValue.Value;
CabinValue = player.houseskins.CabinValue.Value;
DiamondValue = player.houseskins.DiamondValue.Value;
InfectionValue = player.houseskins.InfectionValue.Value;
PurpleCrownValue = player.houseskins.PurpleCrownValue.Value;
RedValue = player.houseskins.RedValue.Value;
TrophyValue = player.houseskins.TrophyValue.Value;
RobuxValue = player.houseskins.RobuxValue.Value;
GhostsPumpkinsBatsValue = player.houseskins.GhostsPumpkinsBatsValue.Value;
}
local playerid = "Player_" .. player.UserId
local success, err = pcall(function()
ds:SetAsync(playerid,datatosave)
end)
--if success then
--print("data saved!")
--else
--print("data failed to save!")
--end
end)
end)
Thank you for reading! Have a nice day!