local success, errormessage = pcall(function()
DataStore:SetAsync(Player)
end)
if not success then
local Retries = 0
repeat
local worked = pcall(function()
DataStore:SetAsync(Player)
end)
Retries += 1
warn(Retries)
task.wait(1)
until
worked or Retries >= 5
print(Retries)
end
This is my code, basically I’ve purposely made it fail so that I can see how it retries, I used to make it retry with a task.wait(.1) but I thought that was too fast because you can only send 1 setasync/getasync call per second according to the equation that they give you with 1 player.
The problem is it only retries once instead of 5 times. When i switch it to task.wait(0.1) it does all the times its required to. It doesn’t throttle but i’m worried it might in a live game if its task.wait(0.1)
You seem to be defining worked inside the repeat block, instead of defining it outside and setting it from within
Also… the limit is 60 + nPlayers * 10 per MINUTE
Oh yes, nevermind, I’m dumb, in repeat loops, all the variables declared inside can be used for the “until”
I’m actually not sure, the repeat loop shouldn’t really quit until either retries is 5 or the pcall works, have you tried printing worked to see if it somehow worked?
i’ll try printing worked but it really shouldn’t because im setting the key as an instance. usually when i make task.wait(1) it only retries once and then it never does again, whereas with tsak.wait(0.1) it retries all 5 times.
Wait a minute is this jsut a tip though? Is this not an actual fix to the problem? Also why would you need to return setasync because it doesn’t really return anything useful.
You may as well go straight into the retry loop, usually it’s a good idea to slow down the request rate too to avoid the accumulation of multiple players failing at the same time then hitting the rate limits.
local retries = 0
repeat
local success, errormessage = pcall(function()
return DataStore:SetAsync(Player)
end)
if not success then
retries += 1
warn(retries)
task.wait(retries)
end
until success or Retries >= 5
--I would also add:
if retries == 5 then
warn(Player.Name, "data not saved")
--additional handling/warning etc
end
The warning message is “argument 2 missing or nil” and I just tried out @Wigglyaa’s method but it still only prints 1 retry.
Players.PlayerRemoving:Connect(function(Player)
local SaveData = {
Time = Player.leaderstats.Time.Value,
RobuxDon = Player.leaderstats.RobuxDon.Value
}
local retries = 0
repeat
local success, errormessage = pcall(function()
return DataStore:SetAsync(Player)
end)
if not success then
retries += 1
warn(retries)
task.wait(retries)
end
until success or retries >= 5
--I would also add:
if retries == 5 then
warn(Player.Name, "data not saved")
--additional handling/warning etc
end
end)
The thing is though I don’t want it to work, because I want to test the retry system. my data saving system already works i’m just testing my retry system.
And the problem with my retry system is that it only retries once instead of 5 times if I make the delay longer. If I make the task.wait one second it will only retry once for some reason.