How would I go beyond 9.22Q limit in leaderboard?

I’ve had an issue with the 9.22Q limit with the Number Values, and I can’t find how to use any module that would expand that limit, here’s the script :

local DataStoreService = game:GetService("DataStoreService")
local playerDataStore = DataStoreService:GetDataStore("PlayerData")

-- Function to save player data
local function savePlayerData(player)
	local success, errorMessage = pcall(function()
		local data = {
			["Rebirth"] = player.leaderstats.Rebirth.Value,
			["Clicks"] = player.leaderstats.Clicks.Value,
			["Multiplier"] = player.MultiplierFolder.Multiplier.Value,
			["RebirthMultiplier"] = player.MultiplierFolder.RebirthMultiplier.Value,
		}
		playerDataStore:SetAsync(player.UserId, data)
	end)

	if not success then
		warn("Failed to save data for player " .. player.Name .. ": " .. errorMessage)
	end
end

-- Function to load player data
local function loadPlayerData(player)
	local success, data = pcall(function()
		return playerDataStore:GetAsync(player.UserId)
	end)

	if success and data then
		player.leaderstats.Rebirth.Value = data.Rebirth or 0
		player.leaderstats.Clicks.Value = data.Clicks or 0
		player.MultiplierFolder.Multiplier.Value = data.Multiplier or 0
		player.MultiplierFolder.RebirthMultiplier.Value = data.RebirthMultiplier or 0
	else
		player.leaderstats.Rebirth.Value = 0
		player.leaderstats.Clicks.Value = 0
		player.MultiplierFolder.Multiplier.Value = 1
		player.MultiplierFolder.RebirthMultiplier.Value = 1
	end
end

-- Function to setup leaderstats
local function setupLeaderstats(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local rebirth = Instance.new("IntValue")
	rebirth.Name = "Rebirth"
	rebirth.Value = 0
	rebirth.Parent = leaderstats
	
	local clicks = Instance.new("IntValue")
	clicks.Name = "Clicks"
	clicks.Value = 0
	clicks.Parent = leaderstats
end

local function setupMultiplier(player)
	local multiplierFolder = Instance.new("Folder", player)
	multiplierFolder.Name = "MultiplierFolder"
	local multiplier = Instance.new("NumberValue", multiplierFolder)
	multiplier.Name = "Multiplier"
	multiplier.Value = 1
	local PetMultiplier = Instance.new("NumberValue", multiplierFolder)
	PetMultiplier.Name = "PetMultiplier"
	PetMultiplier.Value = 2
	local RebirthMultiplier = Instance.new("NumberValue", multiplierFolder)
	RebirthMultiplier.Name = "RebirthMultiplier"
	RebirthMultiplier.Value = 1
end

local function addMultiplier(player, amount)
	player.MultiplierFolder.Multiplier.Value += amount
end

local function addClicks(player)
	local multiplier = player.MultiplierFolder.Multiplier.Value
	local rebirthmultiplier = player.MultiplierFolder.RebirthMultiplier.Value
	local petmultiplier = player.MultiplierFolder.PetMultiplier.Value
	
	player.leaderstats.Clicks.Value += 1*multiplier*rebirthmultiplier*(petmultiplier-1)
	-- print("Clicks : "..1*multiplier*rebirthmultiplier*(petmultiplier-1))
end

local function addRebirth(player)
	player.leaderstats.Rebirth.Value += 1
	player.MultiplierFolder.RebirthMultiplier.Value += 2
	player.leaderstats.Clicks.Value = 0
end

-- Player added event
game.Players.PlayerAdded:Connect(function(player)
	setupLeaderstats(player)
	setupMultiplier(player)
	loadPlayerData(player)
	-- addMultiplier(player, 1)
end)

-- Player removing event
game.Players.PlayerRemoving:Connect(function(player)
	savePlayerData(player)
end)

game.ReplicatedStorage.Events.ClickEvent.OnServerEvent:Connect(function(player)
	addClicks(player)
end)

game.ReplicatedStorage.Events.RebirthEvent.OnServerEvent:Connect(function(player)
	addRebirth(player)
end)

-- Bind to close event
game:BindToClose(function()
	for _, player in pairs(game.Players:GetPlayers()) do
		savePlayerData(player)
	end
end)

Try using a int value instead of a number value, maybe it will solve the problem?

You indirectly found the solution, I used Int Values instead of Number Values, but when I changed to Number Values it worked, thanks a lot

1 Like

No problem, have fun with your simulator game! Or idk the game your working on.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.