DataStore + Scoreboard

I am trying to create a scoreboard in my game that will be displayed server-wide. I figured this would be easier to explain in a ‘timeline’ sort of manner:

  • There are a list of groups that are official and supported by the game, and these groups have their info in a folder in the game already.
  • Player1 is in “Group1” and has it selected in his settings which is accessed through data.
  • Player1 kills Player2 in the arena,
  • Player1 gets Player2’s UserId saved and logged, so that they cannot receive a point from killing Player2 again.
  • Player1 continues to kill more players until he has got enough points to be placed on the scoreboard.
  • Every time the scoreboard refreshes, it loads all the top 100 player’s scores, their selected group, and lists them.
  • The scoreboard shows Group1’s logo, followed by Player1’s name, and Player1’s kill score.
  • The scoreboard script adds up all of the groups’ scores on the top 100.
  • The scoreboard lists the top 5 groups that has the highest total scores of those 100.

I would prefer if the top 100 would be top 500, but I’d rather have smooth + functional > huge quantity.
What I already have set up is the scoreboard showing up and listing players, what I need now is the way to get their selected faction, via :GetAsync on the settings DataStore, and so forth. The issue is, I don’t know any way to do this aside from that method I said. It seems very crude to me and I think if I somehow found a way to make the scoreboards draw from one source, it’d be much nicer. Any advice?

So the main issue here is that you’re having trouble accessing the player’s faction? Is this your only issue or are you experiencing anything else? I was typing for a long time thinking there was more to this issue.

You’re probably going to have to use that supposedly crude method of storing a player’s faction. Unless you use something else like a Google Spreadsheets database, you wouldn’t be able to access their faction if they were offline or in another server.

I’m intrigued about the Google Spreadsheets database, can I use that as a way for everyone to grab the info needed? What I mean is like, the google spreadsheet has the top player’s scores, and then the script in game sorts it?

In all honesty I just want to avoid spamming DataStore Gets and Sets, makes me a lil anxious aha.

Google Spreadsheet database is like a website version of a DataStore. It’s the only real method I know of using datastores or pseudo datastores without overspending your limits or constantly accessing data stores. You can certainly use a Google Spreadsheet as a band-aid alternative, since with Http requests you get a limit of 500/minute over regular data store limitations.


Oh you know what actually, I was playing a game and had a thought about what you could do.

Before I get into it, it’s important to know:

  • This is only really helpful if a player can’t change their factions
  • If a player can change their faction, then this method will only be useful if their kills go towards the faction they have selected at the time, meaning if they change factions, their kills from thereon go to their selected one and not to another one

The method:

  • Have OrderedDataStores with the keys being a way to identify the group (i.e. GroupId)
  • Have the values be the number of kills that Roblox group has
  • When a player kills, the value of both their own score and the group’s score get incremented
  • Call GetSortedAsync on this, only use the top 5 results pulled (you can make your page size 5 and only iterate through one page of what’s returned)
  • Use GetGroupInfoAsync(GroupId) to get the group’s full name and emblem from the id
  • Display the groups on the board like you would players using the information from the previous step

With one fell swoop, one data store call and you’re good to go. If what you’re looking for entails only current factions, then this is not something for you. This method is more useful for compiling top groups alongside top players. It wouldn’t be useful if when players switch factions, their previous group(s) lose the player’s kill scores and it gets added up elsewhere.

1 Like

So if a group has 500 people spread out in different servers, and then miraculously all 500 of those people get an increase of 1 score, it’ll function perfectly fine?

Should. If it doesn’t, you’ll probably want to compile the score in value objects and then increment the score to void datastore limitations either every few seconds, when the player leaves or if the server closes. It’s the closest you can get to “live results” without those limits screaming at you.

I wouldn’t recommend an increment every time someone gets a kill, but would rather do all the sets before I pull pages from my OrderedDataStore. This means data updates first before getting displayed. If you increment every kill, you could run out of requests pretty quickly.

The key is to remember data store limits and work with them in mind. You can also use this nifty function to your advantage.

1 Like

Thank you for the information. And I’d like to humor another possible method, now would it be possible to have one single script do all the work, and have all servers just grab the list, similar to the spreadsheets but all through roblox?

It all relies on how you organize your coding. You can do it through one script, through several, through modules. There is no “proper” way to do it, but there are majorly preferred methods and others that you should generally not use in either public or private projects, with or without a team.

And if it’s a large game with player spikes would the method work?

I think as of right now, the only foreseeable issue is regarding data store (or if you’re using Spreadsheets, Http request) limitations. Your limits are determined by how many players are online in a server (or servers? I’m quite sure limits only pertain to the server that the code is running on, not across the entire game). The method(s) I’ve mentioned would still work in larger servers. But then again, as it usually goes in scripts, you can have all kinds of pointers and methods but it comes down to how you code it and work towards imposed limitations.

Alright, and last thing! So I have the player’s settings as a DataStore which will get :GetAsync()'d by the scoreboards in every server and I’m curious if the player who is getting their Settings data grabbed will have their requests throttled, as well as if only like 60 servers can handle the grabs, or if it’s completely fine.

Basically how is the budget ran? Like I hope that I can do it that way because if not I have no idea haha

Requests will only be throttled if you attempt to make a Data Store call while not having enough budget for the request in that minute. The budget is the same as what’s listed on the Data Store Errors and Limits page.

Request budget math formula is base + (numPlayers * value). Exception to the last table slot, where you can only write to the same key 6 times per second, along with aforementioned limits. Writing to the same key in less than 6 seconds will throttle.

And the budget is per server or the entire game?

Per server. Limitations are separate for the whole game.

So I’m guessing that 500 different servers starting up and then :GetAsyncing the Top Player’s settings data, will get throttled to all hell?

(Due to it being the same key?)

This probably shouldn’t be the case. Each server has a different run time so what happens in this scenario is variable. Each server could be calling a data store method at a different time (i.e. if you have an autosave feature for 60 seconds, not every server will perform a save at that time).

Even 5K+ players miraculously at one time?