I want to use a global leaderboard for my game, but every time i start up the game, the only one on the global leaderboard is the richest person, BUT! the thing that bothers me is that i tried printing the result print(topTen) and it resulted all the data including the other people that aren’t that rich, but on the leaderboard still nothing… I tried many things AdvanceToNextPageAsync, tables and more, even tried other leaderboards but nothing, still the same result.
–local DataStore = game:GetService(“DataStoreService”)
–local StatsDataStore = DataStore:GetOrderedDataStore(“J1BEV56415”) --Make It Hard So Hacker Cant Guess It
local DataStoreService = game:GetService(“DataStoreService”)
local PointsODS = DataStoreService:GetOrderedDataStore(“MoneyGL”)
local ResetTime = script.Parent.TimeUntilReset
local Time = script.Parent.Time.Value
Time = 8
while wait(1) do
Time = Time - 1
script.Parent.Parent.ResetTime.TextLabel.Text = "Resetting in " .. Time .. " seconds..."
if Time == 0 then Time = ResetTime.Value
for i, plr in pairs(game.Players:GetChildren()) do
wait()
PointsODS:SetAsync(plr.UserId, plr.leaderstats:FindFirstChild("Money").Value)
print(plr.Name.." added.")
end
for i, leaderboardRank in pairs(script.Parent:GetChildren()) do
if leaderboardRank.ClassName == "Frame" then
leaderboardRank:Destroy()
end
end
local success, errorMsg = pcall(function()
local pages = PointsODS:GetSortedAsync(false, 15)
local topTen = pages:GetCurrentPage()
print(topTen)
for i,v in pairs(topTen) do
print(game.Players:GetNameFromUserIdAsync(tonumber(v.key)))
local name = game.Players:GetNameFromUserIdAsync(tonumber(v.key))
local id = tonumber(v.key)
local statsname = v.value
wait(0.1)
local Gui = script.Top:Clone()
Gui.PlrName.Text = name
Gui.Rank.Text = "#" .. i
Gui.Amount.Text = statsname
Gui.Parent = script.Parent
if Gui.Rank.Text == "#1" then
Gui.Color.Value = Color3.fromRGB(255, 255, 0) --Top 1 Background Color
script.Parent.Parent.Parent.Parent.Top1.Configuration.userId.Value = id
script.Parent.Parent.Parent.Parent.Top1.Tags.Container.pName.Text = name
end
if Gui.Rank.Text == "#2" then
Gui.Color.Value = Color3.fromRGB(98, 98, 98) --Top 2 Background Color
script.Parent.Parent.Parent.Parent.Top2.Configuration.userId.Value = id
script.Parent.Parent.Parent.Parent.Top2.Tags.Container.pName.Text = name
end
if Gui.Rank.Text == "#3" then
Gui.Color.Value = Color3.fromRGB(255, 85, 0) --Top 3 Background Color
script.Parent.Parent.Parent.Parent.Top3.Configuration.userId.Value = id
script.Parent.Parent.Parent.Parent.Top3.Tags.Container.pName.Text = name
end
end
--[[
--local data = StatsDataStore:GetSortedAsync(false, 15)
--local StatsPage = data:GetCurrentPage()
for i,v in pairs(StatsPage) do
print(game.Players:GetNameFromUserIdAsync(tonumber(v.key)))
local name = game.Players:GetNameFromUserIdAsync(tonumber(v.key))
local id = tonumber(v.key)
local statsname = v.value
wait(0.1)
local Gui = script.Top:Clone()
Gui.PlrName.Text = name
Gui.Rank.Text = "#" .. i
Gui.Amount.Text = statsname
Gui.Parent = script.Parent
if Gui.Rank.Text == "#1" then
Gui.Color.Value = Color3.fromRGB(255, 255, 0) --Top 1 Background Color
script.Parent.Parent.Parent.Parent.Top1.Configuration.userId.Value = id
script.Parent.Parent.Parent.Parent.Top1.Tags.Container.pName.Text = name
end
if Gui.Rank.Text == "#2" then
Gui.Color.Value = Color3.fromRGB(98, 98, 98) --Top 2 Background Color
script.Parent.Parent.Parent.Parent.Top2.Configuration.userId.Value = id
script.Parent.Parent.Parent.Parent.Top2.Tags.Container.pName.Text = name
end
if Gui.Rank.Text == "#3" then
Gui.Color.Value = Color3.fromRGB(255, 85, 0) --Top 3 Background Color
script.Parent.Parent.Parent.Parent.Top3.Configuration.userId.Value = id
script.Parent.Parent.Parent.Parent.Top3.Tags.Container.pName.Text = name
end
end
--]]
end)
end
end