DataStore2 player-independent datastores

I’m trying to use DataStore2 to manage data for my game.

However, I’ve run into an issue that I can’t seem to solve. I need to be able to search a database of all license plates for the police mobile data terminal. ex: when a police officer looks up the plate “1234567”, it should say “owned by Deferend, white 4 door sedan”.

I figure that I have to use a datastore not linked to any players, but I’m not sure how to go about that with the way DataStore2 works. Is there something I’m overlooking here?

DataStore2 does not support non-player/global keys for data storage. You will have to use the normal DataStore API provided by roblox to do this for yourself.


If I were to store license plate data under each player with DS2, would there still be a way to search by plate number?

As far as I’m aware, no. You will not be able to search by plate number directly. You will only be able to check what car a specific player owns.

You could do something hacky like fetching the data of all player’s in the server, and then looping through it to see if you can find a match of plate numbers, which will tell you who owns it.
One could argue that this isn’t very efficient or orthodox, but on the other hand if you use a global key that stores a dictionary of thousands of license plates and their owners, car information, etc, it could get quite big.
I would like to encourage discussion on this though, as I’m also not certain on which method is better to use.

1 Like

No. The problem you will have is that Roblox data stores do not allow querying by data that is saved. You will have the save separate keys using the liscense plate string as the key and information about the owner and vehicle as the value.

1 Like

This is an interesting dilemma. With the fetch and loop method, that wouldn’t return player data from players not in the server, right?

Correct, you’ll only be able to fetch data from players currently in the server. This has its limitations as I’m sure you’ve already figured out - if you look up a plate and the user is not in the game you won’t find an owner, meaning you won’t know whether it’s because nobody owns the plate, or if the owner just isn’t present. In this case you’re kind of forced to use the global key method.

1 Like

That’s unfortunate. I guess this requires that I switch to using the regular DataStoreService API. Do you have any recommendations as to the most secure and least disaster-prone datastore handler?

I myself don’t use any currently. If you search for DataStore in #resources:community-resources, you’ll find quite a few. I suggest doing some research, considering the available options and choosing what’s best for you.


See post here: