You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
I want to create a monthly leaderboard. It may sound very simple.
However, i don’t want to constantly creating global datastores each month and leave them there forever, aka bloating the datastores. Well, we can say it as “1 global datastore” in short.
The solutions along with issues
I know a method of creating new global datastores by using DataTime library (retrieving the name of current month and year), but you know the deal.
Oh, and also i tried to use MemoryStorageService, but it doesn’t order keys by highest value.
I tried to find methods online, but either nobody didn’t know, or OP didn’t tell.
I will leave a thank note if you know how to fix that problem
Why not use global datastores?
Even if they bloat forever, it’s Roblox’s problem not yours + they take very little memory.
Assuming a key-value integer pair in an ordered data store takes 128 bytes, if 10K players play your game throughout one month, it’s only 1.28 MB per month.
MemoryStores also work, use sorted map for sorting.
First thought that came to my mind is to just delete all information in the DataStore and reuse it. With a quick search I found this: Script that can remove all data stores in your game
It removes data from all DataStores but surely it can be modified to clear only 1 DataStore.
It would work if i was planning to reset leaderboards manually, but not really good method for me.
Same as making it automatically.
I assume all methods must be related to memorystorageservice. Example:
I can create new temporary datastores each month and keys will limited up to 32 days, so they will get wiped out later. But the problem is that i can’t make it work with sorting the highest value like what ordereddatastore does for you
Sorry for editing messages too much. Sometimes, i feel like i did not phrase sentences correctly plus adding more info
Modifications:
Line 66 : Change “Value” with your value
Line 83 : Make systems that adds ui into frame like template:Clone() and something like that
Line 32 : If you have other data store that save monthly progress you can resert it using “YourDataStore”:RemoveAsync(Entry.Key) but your key for
global data store and regular data store must be safe otherwise it won’t work
This is terrible.
Not only datastore limits can be hit due to RemoveAsync spam, it also “refreshes” the ordered data store on every single server.
It should never be used in a live game.
Any real reason why you can’t use an ordered data store dynamically changing the version each month?
This is the right way to do that, not the flawed code you marked as a solution.
I just realized that this code is not going to work with huge scales today. Yesterday i was tired and my task was create a decent monthly leaderboard system. Although, it looked promising for me.
Looks like i have to use this.
Thanks for pointing tho