Wanting it to display the ImageLabel Of Top 20 People to donate.
local MaxItems = 20
local MinValueDisplay = 1
local MaxValueDisplay = 10e15
local UpdateEvery = 60
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetOrderedDataStore("GlobalLeaderboard_Robux")
local SurfaceGui = script.Parent["Leaderboard-ROBUX"]
local Sample = SurfaceGui.MainPlayerFrame
local ItemsFrame = SurfaceGui.MainFrame
local Players = game:GetService("Players")
function AddCommas(num)
return tostring(math.floor(num)):reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-?)$","%1"):reverse()
end
local function GetItems()
local Data = DataStore:GetSortedAsync(false, MaxItems, MinValueDisplay, MaxValueDisplay)
local TopPage = Data:GetCurrentPage()
for i, v in ipairs(TopPage) do
local UserId = v.key
local Value = v.value
local Username = "[N/A]"
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size180x180
local content, isReady = Players:GetUserThumbnailAsync(UserId, thumbType, thumbSize)
local Success, Error = pcall(function()
Username = game.Players:GetNameFromUserIdAsync(UserId)
end)
local Item = Sample:Clone()
local PlayerImage = Sample.NameFrame:WaitForChild("Picture")
Item.Visible = true
Item.Name = Username
Item:WaitForChild("NameFrame").PlayerName.Text = Username
Item.LayoutOrder = i
Item.RankFrame.RankNum.Text = i
Item.AmountFrame.AmountNum.Text = "R$: " .. AddCommas(Value)
PlayerImage.Image = content
Item.Parent = ItemsFrame
if i == 1 then
local NPC = game.Workspace.NPC
Item.RankFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
local First = SurfaceGui.First:Clone()
First.Parent = Item.RankFrame
NPC.Head.Tag.Container.User.Text = Username
NPC.UserId.Value = UserId
elseif i == 2 then
Item.RankFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
local Second = SurfaceGui.Second:Clone()
Second.Parent = Item.RankFrame
elseif i == 3 then
Item.RankFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
local Third = SurfaceGui.Second:Clone()
Third.Parent = Item.RankFrame
elseif i <= 4 then
Item.RankFrame.BackgroundColor3 = Color3.fromRGB(170, 0, 255)
end
end
end
while true do
for i, v in pairs(game.Players:GetPlayers()) do
local Stats = v.PlayerStats:WaitForChild("RobuxSpent").Value
if Stats then
pcall(function()
DataStore:UpdateAsync(v.UserId, function(Value)
return tonumber(Stats)
end)
end)
end
end
for i, v in pairs(ItemsFrame:GetChildren()) do
if v:IsA("Frame") then
v:Destroy()
end
end
GetItems()
wait(UpdateEvery)
end
