Timed Leaderboards

Hi all. I’m struggling to create a timed (daily/monthly) leaderboard. I’ve looked for solutions and as a result, I’ve created 2 ordered data stores, one for the daily leaderboard and one for the monthly leaderboard. In addition, I’ve made functions that find the dayID and monthID but I’m not sure how I implement these IDs, whether to use them as part of the key or the value.
At the moment, I save the ID with the value to the UserID.

If someone can help with the logic of this, or give any suggestions it would be greatly appreciated. Thanks

I believe it would be best for you to create and use new ordered data stores for each new day and month.
To do this programmatically, you can use math.floor(os.time() / SecondsInOneDay) and math.floor(os.time() / SecondsInOneMonth) as names for getting and setting individual ordered data stores.

You would then use key-values as normal for pushing data to the leaderboard. (With the key as the user ID and the value of their score/points/etc)

1 Like

Thank you very much,

I had this system in previously but I felt like it wasn’t very storage efficient? What happens to the datastores from past days and months?

Yes, you’re right. It’s ridiculously space-wasteful.

Unfortunately roblox doesn’t provide any nuclear-bomb like function for deleting an entire data store. You could of course set up some kind of low-priority script that checks if you have the extra resources to delete old data store data, and slowly clean whatever extra data that was left behind.

(then again, you’re not the one paying for the database, so ¯\_(ツ)_/¯ )

2 Likes