Hello!
I’m trying to make a game where every time a player clicks a part, a number goes up by 1 (cooldown of 15 seconds). This number is shared so if 2 players click the part it becomes 2. What I want to aim for is this number being synced across all servers within the game, so if one player clicks the button, and in a different server 3 people click the button, 4 will show up as the number.
I know that this can’t be achieved in real time, but I was hoping to get advice on how to make a system where something like every 5 minutes (or every minute if it does not reach the limits of messagingservice), all the servers calculate how much the number has increased by and then replicate it to all the servers what the final number is. Ideally right after this calculation all the servers would have the same number until players start clicking the part, and it will be out of sync for 5 minutes until there is another calculation that tallies up again how much increase there was in total over all servers. In the end, every player’s click is counted towards the final number.
A few worries I have:
- I assume I would use messaging service to tally up the increases for each server, but what server does the tallying and calculation, and then returns the final synced amount to all the rest of the servers?
- How do I datastore the value properly, so that if one server has the number 10 and another has 8, but the server with 10 saves the key as it shuts down and then the server with 8 overwrites that number?
- Do I just save the value of the number in a datastore with a single key? Example, do I do:
game:GetService(“DataStoreService”):GetDatastore(“Number”):GetAsync(“Number”)
for getting this single key / number value, and use UpdateAsync/GetAsync for getting/updating the value in the datastore?
Thanks!