How to get Profile Icon?

I’m sure I’ve seen something like this on these forums, but they didn’t ask the specific question I was going to ask.

So basically, I’m trying to create a GUI thing where you click your profile picture (something like the example shown below) to get settings, e.c.t. I’m not sure how exactly I would do it. I’ve heard it needs a specific link, but I can’t seem to find it. Could anyone help?

image

2022 edit: Wow, I’m beyond surprised that this has a lot of views, not to brag or anything. I hope this has helped you!

95 Likes
11 Likes

How else could you do it? My friend did it like this:

script.Parent.Parent.Main.PROFILE.Image = “http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=150&Format=Png&username=”…player.Name

Blockquote “http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=150&Format=Png&username=

I was just looking for the headshot link to the above link.

12 Likes

There’s a few web endpoints listed here for this however is not the officially supported method of obtaining user thumbnails

4 Likes

I’ve tried doing it, but all it does is give a error in the output which reads:

UserId is not a valid member of Players

This is my script:

local player = game:GetService(“Players”)

script.Parent.Parent.Profile_Picture.Image = “https://www.roblox.com/outfit-thumbnail/image?userOutfitId=“..player.UserId..”&width=420&height=420&format=png

9 Likes

You’re trying to get the UserId from the Service Players and not a Player instance.
But I suggest you use GetUserThumbnailAsync as linked above.

5 Likes

You need to further get the localplayer. At the moment, you’re trying to get a UserId from the players service.

Like this:

local player = players.LocalPlayer

Then swap in player

Also, yes. The GetUserThumbnailsAsync method will return a URL which is guaranteed to be correct, so you don’t have to format your URL yourself. Also, it has the added benefit that you can get different types of thumbnail, like head shot, bust and full avatar.

3 Likes

You said you want to get the head shot of the avatar. Simply use this code:

local Players = game:GetService("Players")

local player = Players.LocalPlayer

-- Fetch the thumbnail
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)

-- Set the ImageLabel's content to the user thumbnail
local imageLabel = script.Parent
imageLabel.Image = content
imageLabel.Size = UDim2.new(0, 420, 0, 420)

Note that all this info is off the developer hub post, so maybe check there before you try and come up with your own method for doing this with API endpoints.

187 Likes

Is that in a local script or a normal script?

3 Likes

WHY WOULD YOU NECROBUMP THE THREAD?

But yes, it’s in a local script.

14 Likes

However, you could make it work with a server script. That’s what I did for a random game I made a long time ago.

(@IK1L1 There was no need to bump the thread 2 years later… All the information you need was already there.)

4 Likes

I’m trying to display a picture of the user that owns a tycoon onto a surface gui through a serverscript, mind telling me how you did that? Also, sorry for ‘necrobumping’ the thread but I’ve been looking for a way on how to do this for a while.

anyway, here’s the script I currently have that isn’t working if anyone decides to help.

local Players = game:GetService("Players")

local Profile = script.Parent
local Display = Profile.Display
local ImageLabel = Display.ImageLabel
local Owner = script.Parent.Parent.Parent.Parent.Owner.Value

local ThumbType = Enum.ThumbnailType.HeadShot
local ThumbSize = Enum.ThumbnailSize.Size100x100

script.Parent.Parent.Parent.Parent.Owner:GetPropertyChangedSignal("Value"):Connect(function()
	if Owner ~= nil then
		local Player = Players:FindFirstChild(Owner)
		local UserId = Player.UserId
		print(UserId)
		local content = Players:GetUserThumbnailAsync(UserId, ThumbType, ThumbSize)
		ImageLabel.Image = content
	else
		ImageLabel.Image = "rbxasset://textures/ui/GuiImagePlaceholder.png"
	end
end)

this is in a server script and does not output a warning/error or print.

1 Like

Have you verified that GetPropertyChangedSignal is firing? If you are not receiving any information, it is likely due to the property not firing.

I am unable to tell what Owner is but in my test with the script below. I am able to successfully update the ImageLabel.

local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer

local content = Players:GetUserThumbnailAsync(Player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150)
script.Parent.ImageLabel.Image = content

The structure for this is:

  • StarterGui
    • ScreenGui
      • LocalScript
      • ImageLabel

Result:

image

Side note: Please start a new topic. This will ensure that you get assistance related to your issue or question.

5 Likes

Maybe you need change local owner to

local Owner = script.Parent.Parent.Parent.Parenet.Owner
and change if Owner ~= nil then to if Owner.Value ~= nil then
same to local Player = Players:FindFirstChild(Owner) to local Player = Players:FindFirstChild(Owner.Value)

2 Likes

idk if you will see this but how would I do it so that everyone in the server will see the headshot on the ImageLabel?

1 Like

depends, if it’s on the screen(and you only have to see yours) you can just do it like this:
you can create the image label for everyone on the side of the screen, insert a localscript with this inside of it:

local userId = game:GetService("Players").LocalPlayer.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
script.Parent.Image = game:GetService("Players"):GetUserThumbnailAsync(userId, thumbType, thumbSize)

ofc you can make it even shorter like this:

script.Parent.Image = game:GetService("Players"):GetUserThumbnailAsync(game:GetService("Players").LocalPlayer.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)

big shoutouts to OverEngineeredCode cause it’s literally his script lol

2 Likes