local players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Orderedstores = {}
local MAX_ROWS = 100
local UPDATE_INTERVAL = 15 -- seconds
local ROW_TEMPLATE = ReplicatedStorage:WaitForChild("LeaderboardRow")
function getOrderedStore(CurrencyName)
if not Orderedstores[CurrencyName] then
Orderedstores[CurrencyName] = DataStoreService:GetOrderedDataStore(CurrencyName)
end
return Orderedstores[CurrencyName]
end
function ClearLeaderboard(surfaceGui)
for _, child in ipairs(gui.DataContent:GetChildren()) do
if child:IsA("Frame") then
child:Destroy()
end
end
end
function updateLeaderboard(leaderboardModel)
local background = leaderboardModel:WaitForChild("Background")
local surfaceGui = background:WaitForChild("SurfaceGui")
local currencyName = leaderboardModel:WaitForChild(Currency).Value
local folderName = leaderboardModel:WaitForChild("FolderName").Value
local store = getOrderedStore(currencyName)
local success, pages = pcall(function()
return store:getSortedAsync(false, MAX_ROWS)
end)
if not success then
warn("Failed to get leaderboard data for " .. currencyName)
return
end
** You are now Level 1! **