DataStore Question

I am making a currency system.

The system will have two parts, one for each players cash amount, and another for the “Global Bank” cash.

The global bank will be given money when players make a purchase from the in-game cash store.

Example:

Player buys item from store
Global bank gains 100$

How would I implement this securely to work across multiple servers simultaneously? And make it as accurate as possible?

Edit: While not completely destroying datastore ratelimits^

The MemoryStoreService sounds useful for this.

https://developer.roblox.com/en-us/articles/memory-store

Hi! Isn’t memorystore kinda inaccurate? I’ve heard of large data losses and I’m unsure if it saves for long-periods of time. (What I need.)

I haven’t gotten around to doing much with the MemoryStoreService, I’m just aware of what it does and figured it’d be useful for what you’re trying to do.

I’m not really sure about the accuracy of the MemoryStoreService, you’ll need to wait for someone more experienced to respond.

StatsManager | Saveable & Non-saveable Stats - Resources / Community Resources - DevForum | Roblox
this is a leaderstats maker and a datastore

Will this accurately persist over multiple servers?

What do you mean by multiple servers? Do you mean different games?

If there’s two servers trying to write into the global bank at once - what will happen? I’m not 100% sure as I’ve never done datastores much.

Honestly i agree with the last guy. im not a Datastore guy you should probably wait for someone more advanced than us to respond

Im not a datastore guy too. But I think GlobalDataStore:UpdateAsync works for you.

Working with data on Roblox is very annoying and painful, but in my experience it is usually wise to use a DataStore module, specifically I use ProfileService.

You can read all about it on the provided link, has a ton of great perks and benefits and is easy to use with plenty of documentation.

As for how to code the system, the global bank will need to have a key such as “BANK_001” and each player will need to have their own individual key. Whenever a player makes a purchase you just need to add the value into your bank’s saved key.

Here are some youtube videos on ProfileService which you may find usefull: ProfileService - YouTube

The problem with soley relying on a DataStore solution is that results will cache, so you won’t get live results.

The solution you’re looking for is MemoryStoreService, which is apart of the Roblox API. This allows data to persist across servers in real-time. The main issue is that MemoryStoreService only stores information for a certain amount of time, so that’s why on to of this you still need a data storing solution.

You can use ProfileService for this as @Send_Scripts suggested.

As the owner of StatsManager (which also supports DataStore2 and ProfileService), I’m going to be adding support for Server-side stats in a later update. I’m aiming to automatically embed the MemoryService and Data saving code which are the functionalities you are looking for.