BigLeaderstat - Bigger leaderstat system that goes past the 9.2 quintillion limit

Introduction

First, since multiple giant parts of the project’s functionality were created by other users I’d like to credit them at the very beginning.

Anyways, this project is essentially the end result of me being mad that Roblox wouldn’t natively support integers over 9.2(something) quintillion for big kinds of projects. I set out to make a leaderstat system with data saving and big number support, which this is.

One of my favorite features added in this is the conversion of big numbers to a sortable value in ordered datastores. If you didn’t know, using an ordered datastore for saving values over the limit for Roblox begins to have issues. This module gives you a method that allows you to convert your obsurdly large integers into a number small enough to fit in a datastore and be sorted for things like global leaderboards. You can then convert it back to a rough estimate on the number depending on the size. This function is only for things like global leaderboards, the personal leaderstats are very accurate.

  • I say rough because per floating point (I think), the larger your number is the less accurate per say it’ll be on the actual (global leaderboard?). This will not be noticeable if you round the number.

If that was completely incoherent, please let me know LOL

Showcase:

(5.5 * 10^29) (I think lmao)
image

Get it:

Anyways, here’s the models for you guys! I’d very much recommend reading the ‘documentation’ below this.

  • Non-saving leaderstats: click
  • Automatic data saving version: click

Notes:

  • I’m not a math god, please don’t ask me super complicated mathematical questions lol I just stitched together some modules and made them work yk
  • The toRoughValue and getSortableValue methods are not 100% precise, but they’re very helpful for global leaderboards.
  • Please report bugs to me, this was not originally intended for the public so very specific use-cases may break it.

Community polls:

Would you use this?
  • Yes
  • No

0 voters

Does this seem helpful?
  • Yes
  • No

0 voters

Methods (or documentation)

:setup

This method sets up all the leaderstats and returns some events.

Arguments

<table>
ex:

{
{<name>,<value>},
...
}

Sample code:

ls:setup({
	{"Example",100},
    {"Strings Are Fine","lol"}
})

image

But it also returns some cool events that are chainable!

ls:setup({
	{"Example",100}
}).loaded:Connect(function(player,methods)
	-- methods is just the ls module but yuh 
end).changed:Connect(function(player,stat,value)
    -- do cool stuf here
end)

:add

For number values, you can’t add directly to the value itself since I use strings to support big integers, but you can use this method to add to them. That’s really the only takeback for me.

Arguments

<player>,<string>,<string/integer>
ex:

game.Players.Player1,"Stat","1000000000000"

Sample code:

ls:add(player,"Stat","100000")

:set

This method just directly sets the value of a stat, simple as that.

Arguments:

<player>,<string>,<string/integer>
ex:

game.Players.Player1,"Stat","15"

Sample code:

ls:set(player,"Stat","0")

:get

This method will return the absolute value of the stat. So if you have a massive number, it’ll return the unformatted version.

Arguments:

<player>,<string>
ex:

game.Players.Player1,"Stat"

Sample code:

ls:get(game.Players.Player1,"Stat")

:formatInteger

This method formats an integer like it’d be on the player list.
** It begins shortening it to like “T” or whatever after 10 million (you can change this in the code, mark variable.)

Arguments:

<integer/string>
ex:

10000 or "100000"

Sample code:

print(ls:formatInteger("10000000"))

:getSortableValue

This method is for global leaderboards, converting massive integers into short numbers that can actually be stored in ordered datastores.
** The bigger the number is, the more precision is lost. It does stay precise on the actual leaderstats, just not if you have to shorten it for datastores.

Arguments:

<integer/string>
ex:
1000000000000

Sample code:

local value = ls:get(game.Players.Player1,"leaderboardValueForOrderedDs")
ls:getSortableValue(value) -- or something like "10000000" / 100000

:toRoughValue

This method undoes the above method for global leaderboards or whatever you might use it for.
** The bigger the number is, the more precision is lost. It does stay precise on the actual leaderstats, just not if you have to shorten it for datastores.
** I’d recommend using the :formatInteger method when displaying it

Arguments:

<integer>
ex:

163283573 --> 12345678 thrown through the above method

Sample code:

ls:toRoughValue(163283573)
3 Likes

May I ask, how will you exceed this limit in a normal game?

1 Like

It can be exceeded if there’s like some giant tycoon / simulator that starts giving you insane amounts. Similar to Miner’s Haven / Mining Simulator. It’s just nice to have if it’s possible to go over that limit.

It really depends on what type of game you’re trying to achieve.

1 Like