Best way to create a weekly/monthly leaderboard?

Basically i want to create a leaderboard that stores the best players each week/month.

I cant think wheter to utlilize datastores or memory stores for this use case. Both are nice but they have some different limits.

Datastore is nice since you can store quite a bit(4MB) and they dont have that many limits but id have to manually reset it each week/month.

Memory store also has some nice features such as auto deletion and is a bit faster in regards to datastores. Only issue with that is it has a bit more limits than your regular datastore.

The topics ive found are useful but arent quite what i need(Plz link me any if i did miss any good ones). The ones i found mentioned to create a new datastore each week but surely there must be a better way instead of creating a whole new datastore eack week???

As always! any help is highly appreciated!! :slightly_smiling_face:

2 Likes

You would use DataStores to store the leaderboard Data, use an OrderedDataStore for the leaderboard, and I guess use a regular one to store the Settings, one of the Settings should be time, either being an os.time() value, to calulate the elapsed time, or the Month Number which can be grabbed by os.date(), you can then check if that number changes. Or it the elasped time has reached a certain point to reset the data.

To calculate ElaspedTime, all you are using is subtracting the Current Time by the old time;
os.time() - oldTime

Use the same DataStore key?
You can reuse DataStores, It would be super inconvenient if you has to create new ones each time.

2 Likes

I would take a look at this post as it lists a few methods.

You could also consider tracking dates by using some simple math:

local Hour = 60 * 60
local Day = Hour * 24
local Month = Day * 30.5 -- Leeway as some months have 31 days and others have 30 (we will ignore feb.)

You would then store the above in a datastore and add it to the unix time; once the server starts up check every 10 minutes or so to see if the current unix timestamp is greater or equal to the saved number. This method isn’t the most reliable but it should work decently if you set it up right.

2 Likes

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