I got an error saying this:
[11:24:36.662 - 302: SetAsync request dropped. Request was throttled, but throttled request queue was full.]
11:24:36.663 - Stack Begin
[11:24:36.663 - Script ‘ServerScriptService.Checkpoints Script’, Line 57]
11:24:36.663 - Stack End
I know what this means but I don’t know what to change in my code.
local died = false
local checkpoints = workspace.Checkpoints
local dss = game:GetService("DataStoreService")
local Datastore = dss:GetDataStore("ObbyData")
local Players = game:GetService("Players")
game:BindToClose(function()
for _,Player in pairs(Players:GetPlayers())do
Player:Kick("This server is shutting down")
end
wait(3)
end)
print("Checkpoints leaderstats working")
print("Deaths leaderstats working")
print("Time leaderstats working")
game.Players.PlayerAdded:Connect(function(plr)
local obbyData = Datastore:GetAsync(plr.UserId .. "-obbyStageProgress")
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = plr
local stage = Instance.new("StringValue")
stage.Name = "Stage"
stage.Value = (obbyData and obbyData[1]) or 1
stage.Parent = stats
local wipeouts = Instance.new("IntValue")
wipeouts.Name = "Deaths"
wipeouts.Value = 0
wipeouts.Parent = stats
local second = Instance.new("IntValue")
second.Name = "Seconds"
second.Value = 0
second.Parent = stats
local wipeoutsData = Datastore:GetAsync(plr.UserId)
if wipeoutsData then
wipeouts.Value = wipeoutsData
end
local secondsData = Datastore:GetAsync(plr.UserId)
if secondsData then
second.Value = secondsData
end
local char = plr.Character or plr.CharacterAdded:Wait()
char:WaitForChild("HumanoidRootPart").CFrame = checkpoints[stage.Value].CFrame
char.Humanoid.Touched:Connect(function(touch)
if touch.Parent == checkpoints then
if (tonumber(touch.Name)and tonumber(touch.Name)>tonumber(stage.Value))or touch.Name == "End"then
stage.Value = touch.Name
pcall(function()
Datastore:SetAsync(plr.UserId .. "-obbyStageProgress", {plr.leaderstats.Stage.Value, plr.Deaths.Value, plr.Seconds.Value})
end)
end
end
game.Players.PlayerRemoving:Connect(function(player)
Datastore:SetAsync(player.UserId,{player.leaderstats.Stage.Value, player.leaderstats.Deaths.Value,player.leaderstats.Seconds.Value} )
end)
plr.CharacterAdded:Connect(function(char)
local hrp = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")
hrp:GetPropertyChangedSignal("CFrame"):Wait()
hrp.CFrame = checkpoints[stage.Value].CFrame
humanoid.Died:Connect(function()
if not died then
died = true
wipeouts.Value = wipeouts.Value + 1
wait(5)
died = false
end
end)
local humanoid = char:WaitForChild("Humanoid")
humanoid.Touched:Connect(function(touch)
if touch.Parent == checkpoints then
if (tonumber(touch.Name)and tonumber(touch.Name)>tonumber(stage.Value))or touch.Name == "End" then
stage.Value = touch.Name
while wait(2)do
second.Value = second.Value + 1
end
pcall(function()
game.Players.PlayerRemoving:Connect(function(player)
Datastore:SetAsync(plr.UserId .. "-obbyStageProgress",{player.leaderstats.Stage.Value,player.leaderstats.Deaths.Value, player.leaderstats.Seconds.Value })
end)
end)
end
end
end)
end)
end)
end)
You said you don’t want to change the code, but let me put this anyways. Why don’t you put the Datastores in a table and then do Datastore:SetAsync(player.UserId,Table)?
PlayerRemoving only runs once, there’s no need to add a wait. Also, I just realized you’re not using pcall function. Here’s a fix for your issue.
game.Players.PlayerRemoving:Connect(function(player)
local WhatevertableName = {
game.Players[Player.Name].leaderstats.Stage.Value,
game.Players[Player.Name].leaderstats.Deaths.Value,
game.Players[Player.Name].leaderstats.Seconds.Value
}
local success, fail = pcall(function()
Datastore:SetAsync(player.UserId, WhatevertableName)
end)
if success then print ("Data was successfully saved")
else
print(fail)
end
--What that does is if data saved, it'll print Data was successfully saved, if it failed to save it'll print the error that caused it to fail. This helps catch errors with datastores failing to save.
end)
13:07:23.655 - DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 145159316 (x25)
[Data was successfully saved
13:07:23.658 - DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 145159316 (x5)
[302: SetAsync request dropped. Request was throttled, but throttled request queue was full.]
No and yes because the pcall function said my data has been saved but it didn’t. I went in game, died twice, left and when I came back, the data did not save
local died = false
local checkpoints = workspace.Checkpoints
local dss = game:GetService("DataStoreService")
local Datastore = dss:GetDataStore("ObbyData")
local Players = game:GetService("Players")
game:BindToClose(function()
for _,Player in pairs(Players:GetPlayers())do
Player:Kick("This server is shutting down")
end
wait(3)
end)
print("Checkpoints leaderstats working")
print("Deaths leaderstats working")
print("Time leaderstats working")
game.Players.PlayerAdded:Connect(function(plr)
local obbyData = Datastore:GetAsync(plr.UserId .. "-obbyStageProgress")
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = plr
local stage = Instance.new("StringValue")
stage.Name = "Stage"
stage.Value = (obbyData and obbyData[1]) or 1
stage.Parent = stats
local wipeouts = Instance.new("IntValue")
wipeouts.Name = "Deaths"
wipeouts.Value = 0
wipeouts.Parent = stats
local second = Instance.new("IntValue")
second.Name = "Seconds"
second.Value = 0
second.Parent = stats
local wipeoutsData = Datastore:GetAsync(plr.UserId)
if wipeoutsData then
wipeouts.Value = wipeoutsData
end
local secondsData = Datastore:GetAsync(plr.UserId)
if secondsData then
second.Value = secondsData
end
local char = plr.Character or plr.CharacterAdded:Wait()
char:WaitForChild("HumanoidRootPart").CFrame = checkpoints[stage.Value].CFrame
char.Humanoid.Touched:Connect(function(touch)
if touch.Parent == checkpoints then
if (tonumber(touch.Name)and tonumber(touch.Name)>tonumber(stage.Value))or touch.Name == "End"then
stage.Value = touch.Name
pcall(function()
Datastore:SetAsync(plr.UserId .. "-obbyStageProgress", {plr.leaderstats.Stage.Value, plr.Deaths.Value, plr.Seconds.Value})
end)
end
end
game.Players.PlayerRemoving:Connect(function(player)
local DataTable = {
game.Players[player.Name].leaderstats.Stage.Value,
game.Players[player.Name].leaderstats.Deaths.Value,
game.Players[player.Name].leaderstats.Seconds.Value
}
local success, fail = pcall(function()
Datastore:SetAsync(player.UserId, DataTable)
end)
if success then print ("Data was successfully saved")
else
print(fail)
end
end)
plr.CharacterAdded:Connect(function(char)
local hrp = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")
hrp:GetPropertyChangedSignal("CFrame"):Wait()
hrp.CFrame = checkpoints[stage.Value].CFrame
humanoid.Died:Connect(function()
if not died then
died = true
wipeouts.Value = wipeouts.Value + 1
wait(5)
died = false
end
end)
local humanoid = char:WaitForChild("Humanoid")
humanoid.Touched:Connect(function(touch)
if touch.Parent == checkpoints then
if (tonumber(touch.Name)and tonumber(touch.Name)>tonumber(stage.Value))or touch.Name == "End" then
stage.Value = touch.Name
while wait(2)do
second.Value = second.Value + 1
end
pcall(function()
game.Players.PlayerRemoving:Connect(function(player)
local DataTable = {
game.Players[player.Name].leaderstats.Stage.Value,
game.Players[player.Name].leaderstats.Deaths.Value,
game.Players[player.Name].leaderstats.Seconds.Value
}
local success, fail = pcall(function()
Datastore:SetAsync(player.UserId, DataTable)
end)
if success then print ("Data was successfully saved")
else
print(fail)
end
end)
end)
end
end
end)
end)
end)
end)
If you attempt to save the data multiple times, it’ll be added to the queue and basically doesn’t save instantly. Hold on I’m gonna check it out real quick.