Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

How do I get a player's name from an ID? [closed]

Asked by
Validark 1580 Snack Break Moderation Voter
9 years ago

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?

Locked by adark, M39a9am3R, and TurboFusion

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
5
Answered by
l0cky2013 135
9 years ago

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))

0
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. Goulstem 8144 — 9y
1
Happy now? Now please get rid of that down. l0cky2013 135 — 9y
0
Very happy, thanks. Goulstem 8144 — 9y
0
What if they don't have sets? Validark 1580 — 9y
View all comments (3 more)
1
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). l0cky2013 135 — 9y
0
You could use HTTP service. Goulstem 8144 — 9y
0
This is actually a really nifty hack, l0cky. Where did you learn of this? adark 5487 — 9y
Ad