How would I even go about making this?

Greetings! So I just came here to gather some general information regarding the topic of DataStores.

So I mean, the idea is like, how would I go about making a system, say for example, a tournaments system that updates cross-server depending on what tournament is selected. And then, after a time, it automatically ends the tournament and starts up a new one.

I know I’d need DataStores, most definitely. I guess the question I’m trying to ask specifically is how do you update a DataStore’s value that any other server could update at any time? (this DataStore would hold the cross-server tournament information, this is the server’s DataStore.)

Hopefully there’s enough information here for you to infer what I’m trying to do…forgive me for probably poorly explaining what I’m trying to figure out how to do. Thanks!

6 Likes

You’re asking how to update, and detect updates of, DataStores in real-time. In other words, you want to avoid caching?

1 Like

You’d definitely want to be using UpdateAsync, and not GetAsync > SetAsync firstly, as UpdateAsync is not able to yield, therefore you’re unlikely to get saves overwriting each other.

As for switching between tournaments, that’s quite a tricky one, and the best advice I can give and what I’ve done in the past is that each server first checks the value in the datastore, this value would contain an os.time value and the tournament type as a string, each server checks the os.time value and then overwrites the tournament type and the os.time value if the current os.time value is below a certain amount of time (the amount of time the tournament runs for ?). In the other servers, as the os.time is now below that amount of time, they would then run the tournament the other server set.

An alternative option, and one that would be a lot more efficient, is to run a very basic webpage that simply displays a tournament mode and switches it periodically, then just get this using HttpService from each server.

6 Likes

Thanks for the info, guys!

4 Likes