Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I find out a specific player's stats with a script using datastore?

1 answer

A data store key for each player generally look something like

"Player-" .. player.UserId

So what you can do is something like this

print(pcall(yourDataStore.GetAsync, yourDataStore, "Player-" .. player.UserId));

And it should print their data. You can retrieve their user ID with the player.UserId property if you need this while they are in game.

If you need to access the data even when they are not in the game use Players:GetUserIdFromNameAsync(username) to get the player's ID from their name.

E.g. Players:GetUserIdFromNameAsync("incapaxx") would result in 129574502 since my ID is that number.

Note that this function sends web requests so it is recommended you wrap in pcall, since you cannot guarantee web requests will always be successful and it also errors if no account with the name username exists.

This discussion is preserved as it was. New answers, comments, and votes are closed.