Help with DataStore2

I’ve been having this problem. My project requires a player to sign up and log in to an account. I want to be able to make sure their usernames and tokens are unique, but that would require me to check all username/token entries in the datastore. If I can do that, how would I do it with DataStore2?

to be honest, it just depends on the token, if it’s 64 characters long there’s virtually no chance that 2 tokens will be the same

It’s best to save the keys based on the player’s user-id since every user has their own ID.

the tokens are 20 characters long, which is why there should be a system in place to ensure they’re unique. i want to be able to do something like this:

if tokenTable[generatedToken] then --check through a table of all tokens
    token.new() --generate a new token if the same token already exists
else
    token.set(generatedToken) --set the token to the player's datastore info if it's unique
end

the password should not realy matter everyone can make theire own.
the username howeever is a diferent story.

you can set up your datastore to have the username as the key and the password as the value.

if you are makign an acount and you get that key from the datastore and it returns … username is already in use