How to remove limit from leaderboard?

Okay just looked back at this and realized your problem. The number is over the integer limit (as we know) and can’t save.

If you’re using a regular DataStore, you can simply save the number as a string.

If you’re using an OrderedDataStore, you will need to do a little more than that. Check out this post.

You can divide the number by for example 100 before saving to reduce it and to load it just multiply the number from the data by 100 too.

And how can I do this, tell me?

I use data store in this script to save leaderboard

Thanks for the topic, I didn’t figure it out

Okay try this, i edited this in reply here

--// GENERAL VARIABLES
local DSS = game:GetService("DataStoreService")
local DataStore = DSS:GetOrderedDataStore("test")
local moduleSc = require(game.ReplicatedStorage.Abbreviate)
local dividenumber = 100

--// UI VARIABLES

local UI = script.Parent.SurfaceGui
local basePlayerFrame = UI.BasePlayerFrame
local boardFrame = UI.ScrollingFrame

--// Functions
local function SaveData()
	for _, player in pairs(game:GetService("Players"):GetPlayers()) do
		local plr_key = "id_" .. player.UserId .. "_Strength"


		local Strength = player:FindFirstChild("Strength")
		if Strength and typeof(Strength.Value) == "number" then
			local success, result = pcall(function()
				DataStore:SetAsync(plr_key, math.floor(Strength.Value/dividenumber))
			end)

			if not success then 
				warn(result)
			end
		else
			warn("Strength " .. player.Name)
		end
	end
end


local function getTop10Players()
	local isAscending = false
	local pageSize = 10
	local pages = DataStore:GetSortedAsync(isAscending, pageSize)
	local top10 = pages:GetCurrentPage()

	local top = {}

	for rank, data in ipairs(top10) do
		local dataName = data.key
		local name = game:GetService("Players"):GetNameFromUserIdAsync(dataName:split('_')[2])
		local Strength = data.value

		local currentPlayer =  { Player = name, Strength = Strength, Rank = rank, }
		table.insert(top, rank, currentPlayer)
	end

	return top
end

local function ClearList()
	task.spawn(function()	
		for _, plrFrame in pairs(boardFrame:GetChildren()) do
			if not plrFrame:IsA("Frame") then continue end
			plrFrame:Destroy()
			task.wait(0.25)
		end
	end)
end

local function UpdateList()
	SaveData()
	ClearList()
	local top50 = getTop10Players()

	task.spawn(function()	
		for _, plr in ipairs(top50) do
			local frame = basePlayerFrame:Clone()
			frame.Parent = boardFrame

			frame.name.Text = plr.Player
			frame.Strength.Text = moduleSc.abbreviate(plr.Strength * dividenumber) 
			frame.rank.Text = plr.Rank

			frame.Visible = true
			task.wait(0.25)
		end
	end)
end


task.spawn(function()
	while true do
		UpdateList()
		for count=5,0,-1 do
			script.Parent.Part.SurfaceGui.Count.Text = "Leaderboard Updating In:" .. count .. " seconds!"
			task.wait(1)
		end
	end
end)

DataStoreService: ValueNotNumeric: Sorted datastore values must be integer numbers API: SetAsync, Data Store: test - Studio
20:15:28.882 502: API Services rejected request with error. Error code: 14 Reason: Sorted datastore values must be integer numbers

This did not help in solving the problem

increase the dividenumber until it works.

And remember to multiply the number back after you GetSortedAsync it.

Yes, it does, check the script

Ah yes, apologies. He multiplies the text value rather than the raw data value.

1 Like

I multiplied how much I needed and it worked and now I would like to tell you how it works if the player has a strength of 1e30 and I write in the dividend such 1e30 then it shows and when I type 1e40 it does not show is it possible Make it so that it is automatically reduced to the player’s strength

In order not to constantly multiply, I want it to be done automatically so as not to constantly change

okay so here i added a function that calulcates the scaling factor with the value’s magnitude.

--// GENERAL VARIABLES
local DSS = game:GetService("DataStoreService")
local DataStore = DSS:GetOrderedDataStore("test")
local moduleSc = require(game.ReplicatedStorage.Abbreviate)

local function ScaleFactor(value)
    local magnitude = math.floor(math.log10(value))
    local scale = 10 ^ (magnitude - 2) 
    return scale
end

--// UI VARIABLES
local UI = script.Parent.SurfaceGui
local basePlayerFrame = UI.BasePlayerFrame
local boardFrame = UI.ScrollingFrame

--// Functions
local function SaveData()
    for _, player in pairs(game:GetService("Players"):GetPlayers()) do
        local plr_key = "id_" .. player.UserId .. "_Strength"
        local Strength = player:FindFirstChild("Strength")
        if Strength and typeof(Strength.Value) == "number" then
            local scale = ScaleFactor(Strength.Value)
            local success, result = pcall(function()
                DataStore:SetAsync(plr_key, math.floor(Strength.Value / scale))
            end)
            if not success then 
                warn(result)
            end
        else
            warn("Strength " .. player.Name)
        end
    end
end

local function getTop10Players()
    local isAscending = false
    local pageSize = 10
    local pages = DataStore:GetSortedAsync(isAscending, pageSize)
    local top10 = pages:GetCurrentPage()
    local top = {}

    for rank, data in ipairs(top10) do
        local dataName = data.key
        local name = game:GetService("Players"):GetNameFromUserIdAsync(dataName:split('_')[2])
        local Strength = data.value
        local scale = ScaleFactor(Strength)
        local currentPlayer = { Player = name, Strength = Strength * scale, Rank = rank }
        table.insert(top, rank, currentPlayer)
    end

    return top
end

local function ClearList()
    task.spawn(function()    
        for _, plrFrame in pairs(boardFrame:GetChildren()) do
            if not plrFrame:IsA("Frame") then continue end
            plrFrame:Destroy()
            task.wait(0.25)
        end
    end)
end

local function UpdateList()
    SaveData()
    ClearList()
    local top50 = getTop10Players()

    task.spawn(function()    
        for _, plr in ipairs(top50) do
            local frame = basePlayerFrame:Clone()
            frame.Parent = boardFrame

            frame.name.Text = plr.Player
            frame.Strength.Text = moduleSc.abbreviate(plr.Strength) 
            frame.rank.Text = plr.Rank

            frame.Visible = true
            task.wait(0.25)
        end
    end)
end

task.spawn(function()
    while true do
        UpdateList()
        for count = 5, 0, -1 do
            script.Parent.Part.SurfaceGui.Count.Text = "Leaderboard Updating In:" .. count .. " seconds!"
            task.wait(1)
        end
    end
end)

It worked but it didn’t work that way, that is, for example, I have 1 million forces and the table just shows 100, that is, not 1m and nothing

The abbreviation works, how can this be fixed?

Help me fix it, I was able to do half of it, but I can’t do it any further. I don’t understand why it always says 100 when I have 1m strength

I solved the problem with the way to create a new leaderboard Thanks to those who helped solve the problem