Single-table global leaderboards (alltime + monthly)

hello! today i am releasing an old-ish module that ive held on to for a while.

it’s designed to work as a simple global leaderboard module, but instead of OrderedDataStores or anything like that it will save all players rankings in to one single table. it utilizes serialization (using DataSerializer) to minimize the tables size while it is in the datastore.

this module was made more as a proof-of-concept. i haven’t tested it in a live environment.

Get the module here!

Usage

Module.SaveServer()
Saves all data of all players in the server. You should use this directly before your leaderboards refresh.

Module.GetTop(Stat: string, Amount: number)
Returns the top Amount number of players of a given Stat.

Notes

  • This module is untested in real live environments
  • This module could be improved!
    • Instead of saving all players in a table, only save a truncated version of that (for example top 500)
    • Checks for “dead players” (people who join and leave without gaining any stats)
    • Better monthly memory store resetting. Currently, it’ll attempt to delete it automatically by retrieving the timestamp of the end of the month, using memorystores built-in expiration argument, however times may be off (needs testing)

overall, I think that this concept is pretty cool and I could definitely see it be used, with the right changes made! Looking forward to see who can expand on this :white_heart:

9 Likes

Where do I place the script from the model I got?

1 Like

I’d place it in ServerStorage and then have a separate script use .SaveServer every x amount of seconds, and after saving use Module.GetTop and update the board to display the newly updated top data.

Thank you for creating this module, it allowed me to do this, something I have wanted to do for a long time
image

1 Like