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

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

Asked by 7 years ago

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

Log in to vote
4
Answered by
DanzLua 2879 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

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

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. RafDev 109 — 7y
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? DanzLua 2879 — 7y
Ad
Log in to vote
0
Answered by
Async_io 908 Moderation Voter
7 years ago
Edited 7 years ago

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.

0
The site was shutting down while I was typing this. Figured it already posted, looks like it didn't. Async_io 908 — 7y

Answer this question