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

How can I find a user's profile picture and use it to update a image label?

Hello, I was wondering how I could find a user's profile image and use that image to update an image label in the gui. I imagine I would have to use something like player.userId along with an address to the games main page. How would I get this location of their image?

2 answers

Ok, so we can either get the player's image by using his username, or using his UserId. In the first chunk here it's getting his profile picture by his username.

I am assuming that this is a LocalScript and it is located inside of the ImageLabel.

local player = game.Players.LocalPlayer

function update()

script.Parent.Image= "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username="..player.Name

end

update()

This chunk here is how I would get my profile picture using my username.

script.Parent.Image="http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=DanzLua"

The first method wouldn't get you the right image in studio because your username is either Player1 or Player.

For this part I am using the player's UserId to get his profile picture.

local player = game.Players.LocalPlayer

function update()

script.Parent.Image= "https://web.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userid="..player.UserId

end

update()

This chunk here is how I would get my profile picture using my UserId.

script.Parent.Image= "https://web.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userid=6755068"

I hoped this helped :)

2 comments

0

You should try to use game:service'Players' or game:GetService('Players'), otherwise good explanation for this. The easiest things are the hardest to explain sometimes.

0

@RafDev I've never really used that way, i've just just the game.Players.LocalPlayer, does it make a difference which one I use?

SCRIPT

ImageLabel.Image = 'http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username='...player.Name --You'll have to replace ImageLabel.

EXPLANATION

This is one of the multiple ways you can get a player's picture. This one uses their username. There is also one where you can use a PlayerID. Personally, I like using a Username more, even though it's the script doing the work, and not me.

1 comment

0

The site was shutting down while I was typing this. Figured it already posted, looks like it didn't.

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