Lowest value leaderboards

I have this script for a leaderboard but it shows the highest amount of deaths. How do I make it so it shows the lowest amount of deaths at number 1.

local function updateLeaderboard2()
        local success, errorMessage = pcall (function()
                local Data =WinsLeaderboard2:GetSortedAsync(false, 5)
                local WinsPage = Data:GetCurrentPage()
                for Rank, data in ipairs(WinsPage) do
                       local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
                       local Name = userName
                       local Deaths = data.value
                       local isOnLeaderboard = false
                       for i, v in pairs(game.Workspace.Locations.Leaderboardarea.LeaderboardArea2.Leaderboard.LeaderboardGUI.Holder:GetChildren()) do
                             if v.Name2.Text == Name then
                                  isOnLeaderboard = true
                                  break
                           end
                    end

                     if Deaths and isOnLeaderboard == false then
                            local newLbFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
                            newLbFrame.Name2.Text = Name
                            newLbFrame.TimeSpent.Text = Deaths
                            newLbFrame.Rank.Text = "#"..Rank
                            newLbFrame.Position = UDim2.new(0, 0, newLbFrame.Position.Y.Scale + (.08 * #game.Workspace.Locations.Leaderboardarea.LeaderboardArea2.Leaderboard.LeaderboardGUI.Holder:GetChildren()), 0)
                            newLbFrame.Parent = game.Workspace.Locations.Leaderboardarea.LeaderboardArea2.Leaderboard.LeaderboardGUI.Holder 
                     end
              end
      end)

      if not success then
            print(errorMessage)
      end
end

You would just do opposite of what they did

1 Like

Yeah but how and at what line. I can not seem to find the line in which it sorts the values from smallest to largest.

its the get sorted async function put the false into true

1 Like

Did it work

30char Don’t Mind This

1 Like

Yes and no, I did what you said but my values were all messed up. My deaths were 57 but it said 17 on the leaderboard. The sorting bit worked though.

        local success, errorMessage = pcall (function()
                local Data =WinsLeaderboard2:GetSortedAsync(true, 5)
                local WinsPage = Data:GetCurrentPage()
                for Rank, data in ipairs(WinsPage) do
                       local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
                       local Name = userName
                       local Deaths = data.value
                       local isOnLeaderboard = false
                       for i, v in pairs(game.Workspace.Locations.Leaderboardarea.LeaderboardArea2.Leaderboard.LeaderboardGUI.Holder:GetChildren()) do
                             if v.Name2.Text == Name then
                                  isOnLeaderboard = true
                                  break
                           end
                    end

                     if Deaths and isOnLeaderboard == false then
                            local newLbFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
                            newLbFrame.Name2.Text = Name
                            newLbFrame.TimeSpent.Text = Deaths
                            newLbFrame.Rank.Text = "#"..Rank
                            newLbFrame.Position = UDim2.new(0, 0, newLbFrame.Position.Y.Scale + (.08 * #game.Workspace.Locations.Leaderboardarea.LeaderboardArea2.Leaderboard.LeaderboardGUI.Holder:GetChildren()), 0)
                            newLbFrame.Parent = game.Workspace.Locations.Leaderboardarea.LeaderboardArea2.Leaderboard.LeaderboardGUI.Holder 
                     end
              end
      end)

      if not success then
            print(errorMessage)
      end
end

In that case it just didn’t update that’s why

1 Like

But it updates as soon as I join and every 60 seconds but It didn’t properly.

Didnt what

30char just chilling

1 Like

It updated but the values stayed the same.

Replace get sorted sync into set sorted sync if possible

1 Like

That part I already have at the end in a while loop which updates every 60 seconds.

while true do

	        for _, player in pairs(game.Players:GetPlayers()) do
		local Avg =  math.floor(player.leaderstats["Avg Deaths"].Value + 0.5)
              WinsLeaderboard:SetAsync(player.UserId, player.leaderstats.Seconds.Value,player.UserId, player.leaderstats.Deaths.Value,player.UserId, Avg)
        end

        for _, frame in pairs (game.Workspace.Locations.Leaderboardarea.LeaderboardArea.Leaderboard.LeaderboardGUI.Holder:GetChildren(),game.Workspace.Locations.Leaderboardarea.LeaderboardArea2.Leaderboard.LeaderboardGUI.Holder:GetChildren(),game.Workspace.Locations.Leaderboardarea.LeaderboardArea3.Leaderboard.LeaderboardGUI.Holder:GetChildren()) do
              frame:Destroy()
	        end
        updateLeaderboard()
	updateLeaderboard1()
	updateLeaderboard2()	 
       
	g = g+1
	        print("Updated Seconds Leaderboard!",g)
	print("Updated Deaths Leaderboard!",g)
	print("Updated Avg Deaths Leaderboard!",g)

        wait(60)
end	

Have you tried destroying it and then make a new one

The Frames I meant

1 Like

What do you mean by that? (30c)

Yes, that was always in the script. every thing used to work. all i needed was for it be smallest at number 1.

Did setting it to true sort it by the smallest

1 Like

Yes, but then the values started not updating and not being the right ones.

Here is the answer probably instead of true set it to false and set your math floor symbol into a minus

1 Like

I do not think that is the problem. As I want it be rounded and the rounding does work even now.