I need to figure out what’s wrong with my global leaderboard script. There aren’t any errors, and I’ve debugged it with print()s. It seems to think that there isn’t any data in the Pages table to loop through.
local Leaderboard = game.DataStoreService:GetOrderedDataStore("BasicPlayerData")
local ScrollingFrame = script.Parent
local function UpdateLeaderboard()
for Number, Slot in ipairs(ScrollingFrame:GetChildren()) do
if Slot:IsA("Frame") then
Slot:Destroy()
end
end
local Success, ErrorMessage = pcall (function()
local Data = Leaderboard:GetSortedAsync(false, 10)
local Page = Data:GetCurrentPage()
for Rank, Data in ipairs(Page) do
local Username = game.Players:GetNameFromUserIdAsync(Data.key)
local ProfilePicture = game.Players:GetUserThumbnailAsync(Data.key, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150)
local Template = script.Slot:Clone()
Template.PlayerName.Text = Username
Template.ProfilePicture.Image = ProfilePicture
Template.Parent = ScrollingFrame
end
end)
if not Success then
print(ErrorMessage)
end
end
while true do
UpdateLeaderboard()
wait(10)
end