PlayerToken to Username/ID

I’m looking to get a player’s username via the API & find players based on either their PlayerToken or avatar thumbnail.
https://games.roblox.com/v1/games/PLACE_ID/servers/public?sortOrder=Asc&limit=100 returns PlayerToken, however I’m really not sure what that is or how to use it to grab a username.
If there’s also a way to find a player based on their avatar thumbnail (Ex: https://tr.rbxcdn.com/d8762dab75a5a3f734f34ca285fcaf80/150/150/AvatarHeadshot/Png), that would work as well.

1 Like

First Add a part to detect the player name then add a script inside the part and then try this code :


local Players = game:GetService("Players")
 
local part = script.Parent
local function onTouched(part)
	local player = Players:GetPlayerFromCharacter(part.Parent)
	if not player then return end
	print(player.Name .. " pressed me!")
end
part.Touched:Connect(onTouched)

I hope this helpfull :slight_smile:

2 Likes

To my knowledge, it’s intentionally impossible to get a player’s name from a user list. This is due to widespread spam campaigns in the past which scraped games’ user lists to find active players to message.

There are extensions/browsers scripts available to cross-check a known user’s thumbnail against all players in a known experience. This is one of the practical applications within this limitation.

2 Likes

What you’re trying to do is API abuse. Stop it.

The reason the /v1/games/{placeId}/servers/{serverType} endpoint doesn’t return user information is intentional to prevent external users from viewing the players in a game server without joining it.

Player tokens are a unique user identifier meant to obfuscate the actual user ID. You can’t resolve user information from them.

It’s also not possible to resolve user information from their thumbnail - even if you somehow had the processing power to generate a thumbnail for every single Roblox user, multiple users can have an identical thumbnai, making it impossible to be certain of which user a thumbnail belongs to.

4 Likes

I see, thank you. I’ve mostly wanted to do this to allow moderators in a group to view current players in a server, as well as their avatars, in an attempt to help with reports & exploiters. I’m trying to avoid having to fool around and figure out a way to return it from in game, as that requires more work & a generally more complex system.

It’s quite sad that some players have decided to abuse the previous system that showed the usernames, and were able to stream-snipe or harrase YouTubers or known community members. I will look for an alternative solution to this.

2 Likes

I think the ideal solution is to write code in your game that communicates some information about players with an external webserver and to write your code around that.

Do remember that just because the data is stored externally doesn’t mean you are exempt from GDPR takedown requests - if a takedown request is submitted to you, make sure you erase external data for that user as well.

2 Likes

I may be a bit late to this conversation, but if your still at it, you can view the player usernames if you have edit access to the game. You will need to submit your account cookie with your api request. In addition to that, another solution could be write a python flask api and then have a script in your game to send all player usernames to it. Then you can hook it into a discord bot or whatever. Either way should work as a solution.

EDIT:
Never mind, after a bit of testing it only reveales your username. The only working solution is to make your own API and write an in-game script

Actually, even if users have identical thumbnail, they will always be unique, so it can be possible.

Can you provide an example? That’s not what I’ve found.

(since this post they’ve also added a second layer of obfuscation by limiting the number of thumbs returned and only showing a smaller number of players, so that makes it even more difficult)