Are there other "Keys" than UserId for DataStore

Hello, i learned recently about DataStores, but now i have the problem that i dont know much about the Keys. I only know the key UserId but are there more Keys than UserId that you could paste down? Please do it simple, thank you!

3 Likes

What? The UserId in a key is a unique identifier that is used to retrieve a plaer’s data. The user id doesn’t change, so that’s about the only way you could retrieve someone’s data without merging it with another player.

3 Likes

So there isnt exist another one, cuz im trying to To make a datastore which isnt saved in the players id if this is possible, and yes i asked that last time and got a solution but i dont really understand that one

1 Like

like what can you all use as key

Datastores can have any key. It can be a plain user id, something like Player_{userId} or not even related to user ids at all. You can totally have a key named ServerData or something like that if you want to. Using user ids is just extremely useful for saving player data, since their user id will never change unlike their username

1 Like

You can use any key to index information (imagine datastores as just a big dictionary), but UserIds are majorly used because they’re a unique identifier, something like a username can be changed.

1 Like

You mean i can just do smth like this:

ds:SetAsync(RandomWord,5)
2 Likes

it’s pretty simple tho. You can launch early prepared events even through studio for all servers!
If you set the key value that checks certain amount of time, and change it like :SetAsync(YourKey, true) you can globally do what you coded early.

1 Like

Technically yes, but if it was always the same word everyone would have the same data as it would be the same key. Developers use the Player’s UserId as the Key because it’s unique to the player. Also, if you get a Right to Reassure request, it’s super easy to find the user’s key if you use their UserId as the key! :wink:

All a “key” does is identify a value in the DataStore. UserId is commonly used for player data for the reasons stated above but keys, like in tables, can basically be anything with some exceptions

Alr thank you guys all for help, hope you have a good day

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.