How to save a UNIQUE table in DataStore2 (regardless of the player)?

Currently in DataStore2 the data is saved for each player. Ex: local myData = DataStore2("myData", player).
In addition to the data for each player, I would like to store ONE generic table that will serve for ALL players.
How to save this unique table in DataStore2 for (not using the player)?

1 Like

Yes, I can. And that’s not my question.

1 Like

You can, there’s even a method Store:GetTable(t) that considers missing indexes when deciding to override previous data, with the default value argument.

@rogeriodec_games

Try forking the DataStore2 module so that it doesn’t break when the second argument isn’t a Player object, I remember seeing asserts (could’ve been warns) in there.

Or you know just have a reserved key without using a wrapper

DataStore:SetAsync("key", 10)

and retrieve data from that key, it isn’t going to be relative for every player.

1 Like

That’s the problem. I tried to use a “generic” player (zero) but I got an error: ServerScriptService.DataStore2:483: DataStore2() API call expected {string dataStoreName, Instance player}, got {string, number}.

I don’t want to mess with the original DataStore2 code.
So, in this case, the answer to my original question is: I can’t save a unique table in DataStore2 (regardless of the player). I’ll will always to duplicate this table to all players.

1 Like

Yes, since you can’t with the original code save data for non-player instances or other keys.

Edit: ?

DataStore2 requires a player instance when accessing a datastore. There isn’t anyway to have a standalone datastore without a player instance, without editing DataStore2’s code itself (and if you do you’ll need to make it open source as specified by the license)

1 Like