So this is a global leaderboard which displays the Top Wins from all Data. It works but I noticed that it sometimes doesnt save or it saves to late. I cant find the reason for that doe and I think the script isnt that good rn.
Also I get this Error after 7sec. in studio :
- DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = Paintertable (x3)
Can any good scripters see some problems here?
local TotalWheatODS = game:GetService("DataStoreService"):GetOrderedDataStore("Wins")
local function Handler()
local Success, Err = pcall(function()
local Data = TotalWheatODS:GetSortedAsync(false, 25)
local TotalWheatPage = Data:GetCurrentPage()
for Rank, Data in ipairs(TotalWheatPage) do
local Name = Data.key
local TotalWheat = Data.value
local NewObj = game.ReplicatedStorage:WaitForChild("lbFrame"):Clone()
NewObj.Player.Text = Name
NewObj.TotalWheat.Text = TotalWheat
NewObj.Rank.Text = "#"..Rank
NewObj.Position = UDim2.new(0, 0, NewObj.Position.Y.Scale + (0.08 * #game.Workspace.StatCoinBoard.lbGUI.Holder:GetChildren()), 0)
NewObj.Parent = game.Workspace.StatCoinBoard.lbGUI.Holder
end
end)
if not Success then
error(Err)
end
end
while true do
for _,Player in pairs(game.Players:GetPlayers()) do
TotalWheatODS:SetAsync(Player.Name, Player.Leaderstats.Wins.Value)
end
for _,v in pairs(game.Workspace.StatCoinBoard.lbGUI.Holder:GetChildren()) do
if v.Name == "lbFrame" then
wait()
v:Destroy()
end
end
Handler()
wait(5)
end

1 comment
Try making the wait abit longer, I think you're throttling the datastorage