I am attempting to create a global leaderboard on my latest creation following a similar format to How to make a simple global leaderboard
Storage of player stats works fine along with subsequent retrieval, but when reading the data back using GetOrderedDataStore, it returns no data.
Playerstats are Saved & Loaded successfully using:
local datastore = game:GetService("DataStoreService")
local ds = datastore:GetDataStore("DumpSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local folder = Instance.new("Folder", player)
folder.Name = "leaderstats"
PlayerDumps = Instance.new("IntValue", folder)
PlayerDumps.Name = "Dumps"
PlayerDumps.Value = ds:GetAsync(tostring(player.UserId)) or 0
ds:SetAsync(tostring(player.UserId), PlayerDumps.Value)
end)
Global Leaderboard data is supposed to be retrieved with:
local orderedDatastore = game:GetService("DataStoreService"):GetOrderedDataStore("DumpSaveSystem")
local function Handler()
local Success, Err = pcall(function()
local Data = orderedDatastore:GetSortedAsync(false, 10)
local TotalDumps = Data:GetCurrentPage()
local i=0
print(#TotalDumps)
for Rank, Data in ipairs(TotalDumps) do
local Name = Data.key
local Dumps = Data.value
local NewObj = game.ReplicatedStorage:WaitForChild("IbFrame"):Clone()
NewObj.Player.Text = Name
NewObj.Dumps.Text = Dumps
NewObj.Rank.Text = Rank
NewObj.Position = UDim2.new(0,0, i,0)
NewObj.Parent = game.Workspace.Sheet.SurfaceGUI.Holder
i=i+0.05
end
end)
if not Success then
error(Err)
end
end
However, the print(#TotalDumps)
shows 0. I have very similar functions working fine other games, but this one seems to be causing problems and I can’t seem to see why.
The stats should be shown on the toilet paper to the left of the player on this game [ Content Deleted ] - Roblox