106: MaxValue and MinValue must be integers

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

a global leaderboard in a donation game

  1. What is the issue? Include screenshots / videos if possible!

it didnt work (by the title)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

nothing

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- [ SETTINGS ] --

local statsName = "Donated" -- Your stats name
local maxItems = 100 -- Max number of items to be displayed on the leaderboard
local minValueDisplay = 0 -- Any numbers lower than this will be excluded
local maxValueDisplay = math.huge -- (10 ^ 15) Any numbers higher than this will be excluded
local abbreviateValue = true -- The displayed number gets abbreviated to make it "human readable"
local updateEvery = 15 -- (in seconds) How often the leaderboard has to update
local headingColor = Color3.fromRGB(25, 181, 254) -- The background color of the heading

-- [ END SETTINGS ] --




-- Don't edit if you don't know what you're doing --

local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local DataStore = DataStoreService:GetOrderedDataStore("GlobalLeaderboard_" .. statsName)
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 = { "K", "M", "B", "T", "Qa", "Qi", "Sx"}


local function toHumanReadableNumber(num)
	if num < 1000 then
		return tostring(num)
	end
	
	local digits = math.floor(math.log10(num)) + 1
	local index = math.min(#ABBREVIATIONS, math.floor((digits - 1) / 3))
	local front = num / math.pow(10, index * 3)
	
	return string.format("%i%s+", front, ABBREVIATIONS[index])
end

local function getItems()
	local data = DataStore:GetSortedAsync(false, maxItems, minValueDisplay, maxValueDisplay)
	local topPage = data:GetCurrentPage()

	for position, v in ipairs(topPage) do
		local userId = v.key
		local value = v.value
		local username = "[Not Available]"
		local color = COLORS.Default
		local winners = game.ReplicatedStorage:WaitForChild("Bindables"):WaitForChild("WinnerEvent")
		
		Contents.Items.Nothing.Visible = #topPage == 0 and true or false
		
		local success, err = pcall(function()
			username = Players:GetNameFromUserIdAsync(userId)
		end)
		
		print(username)
		
		if position == 1 then
			color = COLORS.Gold
			winners:Fire(workspace:WaitForChild(username), 1)
		elseif position == 2 then
			color = COLORS.Silver
			winners:Fire(workspace:WaitForChild(username), 2)
		elseif position == 3 then
			color = COLORS.Bronze
			winners:Fire(workspace:WaitForChild(username), 3)
		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 toHumanReadableNumber(value) or value
		item.Parent = Contents.Items
	end
end


script.Parent.Parent.Color = headingColor
Frame.Heading.ImageColor3 = headingColor
Frame.Heading.Bar.BackgroundColor3 = headingColor

while true do
	for _, player in pairs(Players:GetPlayers()) do
		local leaderstats = player:FindFirstChild("leaderstats")

		if not leaderstats then
			warn("Couldn't find leaderstats!")
			break
		end

		local statsValue = leaderstats:FindFirstChild(statsName)

		if not statsValue then
			warn("Couldn't find " .. statsName .. " in leaderstats!")
			break
		end

		pcall(function()
			DataStore:UpdateAsync(player.UserId, function()
				return tonumber(statsValue.Value)
			end)
		end)
	end

	for _, item in pairs(Contents.Items:GetChildren()) do
		if item:IsA("Frame") then
			item:Destroy()
		end
	end

	getItems()

	wait()
	Frame.Heading.Heading.Text = statsName .. " Leaderboard"
	Contents.GuideTopBar.Value.Text = statsName
	wait(updateEvery)
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

this is the error line btw

local data = DataStore:GetSortedAsync(false, maxItems, minValueDisplay, maxValueDisplay)

The problem likely lies with the fact that you’re using math.huge; try using something like 999999999.

1 Like

ok one part closer
I have a new problem now and I testing with different account called “alirobloxerpro”
I tested and it tries to get the player that I tested it before which is “glitchedali” and not “alirobloxerpro”

when alirobloxerpro is in the server and not glitchedali
it tries to find glitchedali at the workspace as the first place in the leaderboard but there is only alirobloxerpro in the workspace and not glitchedali

btw glitchedali and alirobloxerpro are accounts I’m testing with

here is the error:

Infinite yield possible on ‘Workspace:WaitForChild(“GlitchedAli”)’

is there a way I can get a character without the player playing the game?

By character do you mean avatars?

Sounds like this announcement from 3 hours ago might help you out: OpenCloud Ordered DataStores [Public Beta]

yes i want to get the avatar so i can replace an at the first place to the people and add it to the leaderboard

I don’t really know how to use open Cloud ordered datastore, but I will look into the page for information.