SetAsync only working for certain players? (Global Leaderboard)

I’m having lots of trouble figuring out why my global leaderboard won’t update for everyone.

while true do
	for i, player in pairs(game.Players:GetPlayers()) do
		task.spawn(function()
			local cash = playerCash:WaitForChild(player.Name)

			pcall(function()
				print(player.Name)
				
				cashData:SetAsync(player.UserId, cash.TotalCash.Value)
				gemData:SetAsync(player.UserId, cash.TotalGems.Value)
				rebirthData:SetAsync(player.UserId, cash.PlayerRebirths.Value)
				playTimeData:SetAsync(player.UserId, player.Values.PlayTime.Value)

				print(player.Name.. " Cash = ".. cash.TotalCash.Value)
				print(player.Name.. " Gems = ".. cash.TotalGems.Value)
			end)
		end)
	end
	
	task.wait(60)
end

I’m calling all players and using SetAsync to save their place on the leaderboard. However, it only works for some people.

^ An image of me and my alt in-game. You can see it prints my alt’s name, but doesn’t call SetAsync at all while only calling SetAsync for my own account.

I’ve tried searching on google & the devforum and used UpdateAsync instead of SetAsync. No luck. Been stuck on this for days now.

1 Like

What is the error in the pcall?

Also, is the leaderstats initialized for both users?

Heres solutions on how to fix this problem:

  1. Figure out the error.
  2. Make sure the Datastore request is not at it’s limit.

Looks strange ngl
image

I didn’t seem to find an error, it just pauses there. And yes, all values and leaderstats are in both players.

No errors, just pauses. How do I determine if it’s at the data store limit?

you can read about datastore limits here: Data Stores | Roblox Creator Documentation

and you can use: GetRequestBudgetForRequestType to find out how many of your limits you have use

but it looks like your using 4 set requests every minute per player and you have a limit of 10 per player per minute so if your not using the datastore anywhere else it should not hit the limit

I used the sample code and it prints in the output:

Current set/increment budget: 582

Is that number normal or is it too large?

Found out the issue by printing pcall errors. Ordered data stores only support whole numbers.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.