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

How do you show a local player profile picture on an ImageLabel?

Hi, I'm trying to make a horror game and I want a television to show the local player's image. I have tried several blocks of code to make this happen, but the image is always transparent. I am aware of the fact that the following code blocks are messy and unorganized, but I was in a rush to complete them. These codes include: 1:

-- this one was in a block that starts the television change when touched. I cut out a lot of the
--initial code to shorten it. It's in a default script.
local debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
if not debounce then
debounce = true
local hi = game.Players[hit.parent.Name]
game.Workspace.Telly.Screen.Image.ImageLabel="http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username="..hi

2:

--this one I put inside the television itself's screen. I tried it with and without being inside a
--normal and a local script.
local player = game.Players.LocalPlayer.Name

function update()

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

end
 
update()

3:

--this one is the same as the above, but using the UserId instead of the username. It still
--doesn't work. Once again, tried local and default scripts.
local player = game.Players.LocalPlayer.UserId
 
function update()
 
script.Parent.Image= "https://web.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userid="..player
 
end
 
update()

4:

--at this point, i had run out of ideas. This was my last-ditch effort attempt.
script.Parent.Image= "https://web.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userid="..game.Players.LocalPlayer.UserId

I don't what's wrong with these scripts. Please help me fix it.

1 comment

0

Question, what do you mean by "the image is always transparent"

1 answer

GetUserThumbnailAsync


For this purpose you should use the GetUserThumbnailAsync function of the players service. which allows you to get one of 3 types of Thumbnails of the player, those being:

  • HeadShot
  • AvatarBust
  • AvatarThumbnail

They can also be one of 7 thumbnail sizes, those being:

  • 48x48
  • 60x60
  • 100x100
  • 150x150
  • 180x180
  • 352x352
  • 420x420

With that said the Function itself takes in 3 parameters, the player's UserId, the thumbnail type, and the thumbnail size, like:

Players:GetUserThumbnailAsync(UserId,ThumbnailType,ThumbnailSize)

Which can be put into application like this:

--localscript
local players = game:GetService("Players")
local plr = players.LocalPlayer
script.Parent.Image = players:GetUserThumbnailAsync(plr.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size180x180)

In this instance, you would have to set the parent of the localscript to the imagelabel/imagebutton you want to modify


Additional Links


Thumnail Sizes

Thumbnail Types

Hopefully this helped! Be sure to accept if it did!

3 comments

0

stop eating lychees

0

Literally copied and pasted this exact script into a localscript. Still doesn't work. Even tried it with and without FilteringEnabled on.

0

damn, im necrobumping so many things. the endpoints for thumbnails are so messed up

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