Universal saving table?

I have read in many posts that ways exist for players to save tables to a player, using Datastores .
But my question is whether you can actually save 1 Universal table on the Server, to which we could insert new data into and save, could this be done using Serialization or an alternative? or am I going completely wrong about this ?
How would I be able to save the table itself , on it’s own ? if not possible then maybe to every player ?

local store_key = "Attempted Table Save"
local data_key = "data key"
local ds = game:GetService("DataStoreService"):GetDataStore(store_key)
local event = game.ReplicatedStorage.GamepassEvent
 event.OnServerEvent:Connect(function(Player)
   local ids = {}
     table.insert(ids,Player.UserId)
    ds:SetAsync(Player.UserId,ids???)    --Is this even possible?

Because what I want to do is to add player user ids to tables in one game, so I know if players played a game , so that in another game I would reward those players whose ids were in the table,
alternative method provided will also be appreciated.

2 Likes

SetAsync / UpdateAsync / IncrementAsync only accept 1 key, you’ll need to iterate through ids and save it individually.

If I’m not fully getting what you mean, some clarification would be appreciated.

1 Like

I was wondering what the best way is , if there is one at all, to save a table universally , meaning on the server basically, as I don’t want to create a datastore for every player for that, I just want to add user ids to a table , for every player that joins like :

   table.Insert(ids,Player.UserId)

and then save that table somehow, so I could later on use it in another game to see which players played that game and award those players in the latter.
I know this is possible somehow, but what I don’t know is just how exactly .
Maybe using datastores isn’t even necessary for all I know.

Basically the point is to see which players played one game, to award them in the second

This is possible. The only reason why you use the players UserId for the key is because that number is unique to the player and doesn’t change. This means data store keys can be anything you like. With that in mind you can make a unique key that doesn’t related to any player and save your data under that key. The key could be something like, “PastJoined”.

I would advise against what you are doing this way because you will be hitting your data store limits very quickly. Instead you could check if the player has played before by checking if they have any previous data saved because the only way the player would have data is if they have played before. Another method could be to save a value under the players normal data store that tells you if they have played before.

I am a little unsure what you are trying to achieve but from what I can gather using MessagingService could be what you are looking for.

1 Like

But I dont understand how i’ll make sure a player has played in another game , though your reply helped me understand what I could do , for my scenario.

I am sorry but I am a little confused as to what your use case for this is so please could you elaborate? Is your game a universe?

From what I understand at the moment couldn’t you save a table under that player stating each game they have visited?

1 Like

Pretty sure you are looking at an external database to do this type of thing. I honestly don’t know of a way to share data across multiple games unless you are calling out to an external database. I could be wrong though.

1 Like

If all the games are within the same universe then the data is shared between every game within that universe because they share the exact same database. This means you can use data stores normally but the data is available in all the places within that universe.

However if you want to share data to other places not in the same universe then you will need to use an external database. Roblox data stores don’t allow you to transfer data to other games not in the same universe.

3 Likes

Very true. Several of my games use additional servers for things like mini-games, race courses and battle arenas. Those all share the same database because they are all places, tied to an existing game.

My understanding of the question was how to share information from a group, across multiple games. Which I believe is only possible, as you state, using an external database.

3 Likes

“Universal Saving table”, the term pertained to a table that could be accessed by multiple scripts in one game, hence the prefix “universal”.

For example a table created by a script being accessed by another script, doing so through saving the table first into a module (if possible ) or any alternate procedure for the table to be written into.

apologies for delayed elaboration