Hi there! Can someone explain me how the new.LayoutOrder = rank works? So basically this is a global leaderboard, is works very good and i understood everything on it but i don t understand how the order works like this : Dan = 1000, Josh = 500, and dan is top 1, josh is top 2, i thought the layoutorder needs to be new.LayoutOrder = -rank [negated], but in this script is not, i know is the rank index and stuff but i dont understand how the order works, whcih has more priority and etc, if you answer me i ll make sure to make it as accepted answer, please help me i`m desperate..
local dataStoreService = game:GetService('DataStoreService') local players = game:GetService("Players") local template = game.Workspace.GlobalBoard.SurfaceGui.Leaderboard.Template local globalDataStore = dataStoreService:GetOrderedDataStore('MoneyGlobal') local board = workspace.GlobalBoard local template = board.SurfaceGui.Leaderboard.Template:Clone() workspace.GlobalBoard.SurfaceGui.Leaderboard.Template:Destroy() local function update() for _, child in pairs(board.SurfaceGui.Leaderboard:GetChildren()) do if child:IsA('Frame') then child:Destroy() end end local success, err = pcall(function() local data = globalDataStore:GetSortedAsync(false, 40) local page = data:GetCurrentPage() for rank, plrData in ipairs(page) do local new = template:Clone() new.PlrName.Text = game.Players:GetNameFromUserIdAsync(plrData.key) new.PlrAmount.Text = plrData.value new.Parent = game.Workspace.GlobalBoard.SurfaceGui.Leaderboard new.LayoutOrder = rank -- THIS IS WHAT I DON`T UNDERSTAND! end end) end while true do update() wait(math.random(2,5)) spawn(function() for _, plr in pairs(game.Players:GetPlayers()) do globalDataStore:SetAsync(plr.UserId, plr.leaderstats.Money.Value) wait(math.random(2,4)) end end) end