local statsName = "Cash"
local maxItems = 100
local minValueDisplay = 1
local maxValueDisplay = 1e300
local abbreviateValue = true
local updateEvery = 10
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local DataStore = DataStoreService:GetOrderedDataStore("Cash")
local Frame = script.Parent.Frame
local Contents = Frame.Contents
local Template = script.objTemplate
local COLORS = {
Default = Color3.fromRGB(38, 50, 56),
Gold = Color3.fromRGB(255, 215, 0),
Silver = Color3.fromRGB(192, 192, 192),
Bronze = Color3.fromRGB(205, 127, 50)
}
local ABBREVIATIONS = require(game.ReplicatedStorage.SNotation)
local function getItems()
local data = DataStore:GetSortedAsync(false, maxItems, minValueDisplay, maxValueDisplay)
local topPage = data:GetCurrentPage()
Contents.Items.Nothing.Visible = #topPage == 0 and true or false
for position, v in ipairs(topPage) do
local userId = v.key
local value = v.value
local username = "[Not Available]"
local color = COLORS.Default
local success, err = pcall(function()
username = Players:GetNameFromUserIdAsync(userId)
end)
if position == 1 then
color = COLORS.Gold
elseif position == 2 then
color = COLORS.Silver
elseif position == 3 then
color = COLORS.Bronze
end
local item = Template:Clone()
item.Name = username
item.LayoutOrder = position
item.Values.Number.TextColor3 = color
item.Values.Number.Text = position
item.Values.Username.Text = username
item.Values.Value.Text = abbreviateValue and ABBREVIATIONS.short(value) or value
item.Parent = Contents.Items
end
end