I have a table of ID's that my game automatically checks through to see if you are friends with any certain people, but it is a long list, so is there any way I can get the username from one of the ID's?
✓ ANSWER ACCEPTED
How do I get a player's name from an ID?
1 answer
✓ Accepted answer
Sure. This function will return the username from the given id. :)
function UserFromId(userId)
local userSets = game:GetService("InsertService"):GetUserSets(userId) --get the user's sets
for _,v in pairs(userSets) do --iterate through then
if v.Name == "My Models" then --check if this is the player's models
return v.CreatorName --returning the name of the creator of the set "My Models" (the player)
end
end
end
print(UserFromId(261))
This discussion is preserved as it was. New answers, comments, and votes are closed.

7 comments
Explain what you're doing. Don't just give them the answer, they won't know anymore about what how to do this than they already did if you don''t elaborate a bit.
Happy now? Now please get rid of that down.
Very happy, thanks.
What if they don't have sets?
My Models is a mandatory set that is given to every ROBLOX user. You can look at it by clicking "Models" on your inventory tab. If they don't have it, then report it to roblox as a major bug (never).
You could use HTTP service.
This is actually a really nifty hack, l0cky. Where did you learn of this?