How can I make data save for a GAME (not per player)

So I am trying to save data for my game, but not like the regular data saving. With DataStoreService, you can save data linked to a player. But what I’d like to do is have it linked to the game.

For example have an integer which saves how many players have bought a certain pet in the game. And then each time the pet gets bought, that global integer would go up by 1. And this would be over all servers in the game.

Right now I do that by storing data to my UserId using DataStoreService, and then I can SetAsync to it, and GetAsync from another server. So it works, but it’s kind of an inefficient way. That’s why I’m wondering if there is a better way to do it.
So, is this possible? And if yes, how?


You can just use any Key for Datastore.
For example to save data for players you use their UserId. And to save this count you can use “PetsHatchedCount” as a Key.

I don’t think theres any other way to do it, except DataStores. You can also use your own servers that you would need to PAY for.

This can get complex a loot fast, best thing is to make your own server, if you want it on cloud, use 000webhost, if you want to make server, I will post tutorial on that soon, I’m still working on it and I’m missing some parts of it.

It’s quite simple to do this. Just set the key of the datastore to some thing like "PetsBought" instead of Player.UserId.."-PetsBought"


Datastores function using keys, so if you have a datastore called Inventories and, for example, you want to save that player’s inventory separated from everyone else’s, you’d save it with an unique key, like the player’s userId. Here’s an example:

local InventoriesDatastore = game:GetService("DataStoreService"):GetDatastore("Inventories")
local Data = {
	Health = 100,
	Stamina = 43,
	Weapons = {"M16","Glock","M1416","Revolver"},
	PrimaryWeapon = "M16",
	SecondaryWeapon = "Glock"


This will save the table to the key I’ve set, which is the player user id, unique from anyone else.

Now if I wanted to save something to one unique datastore, I’d set a default key, a key I will always use to save that specific data, like so:

local MyGlobalDataStore= game:GetService("DataStoreService"):GetDatastore("GLOBALDATA")
local Data = {
	Gold = 1504,
	Jade = 258,
	Tools = {"Pickaxe","Axe","Shovel","Rock"},
	Money= 1972


Since this time I used the key GLOBALDATA, the data will be saved to that unique scope within the datastore, and if I save or load other data using that key, the same data will always be returned (Unless you change it for other data, obviously).

Alternatively, you can also use Global Datastores which will always save data to the same datastore without the need of a name. But this can be limited if you want to have multiple global datastores. Apologies if this gets confusing.


Oh wow, it’s so much easier than I thought :sweat_smile:
But thank you everyone! (@ShkatulkaGames @THECOOLGENERATOR @Koreacty )