Trouble loading Avatar Thumbnail In game

Hello there,

I am trying to load a player’s avatar in my leaderboard UI and I want it to be of a headshot but it’s making it a full body picture. Can anyone help?

What is Occuring

image

What I want

image

Any help is greatly appreciated.
My Current code:

script.Parent.Image = "http://www.roblox.com/Thumbnail/Avatar.ashx?x=100&y=100&userId=" .. game.Players.LocalPlayer.UserId

You’ll most likely find this to be useful: New image endpoints that can be used in-game!

I know that there was a wiki page for stuff like this, but it seems to be gone.

Edit: After looking around, you can use this to get what you want: Players | Documentation - Roblox Creator Hub

2 Likes

I’ll check it out. I still don’t see a headshot in there though

The second link is exactly what you’re looking for.

1 Like

Thanks I’ll look into it

Would I have to change my code in order for it to work? (Other than the size)

You’d just need to change it a bit.

local content, bool = game.Players:GetUserThumbnailAsync(game.Players.LocalPlayer.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150);
script.Parent.Image = content

I’m assuming that the content variable is a string, but if it’s not you’d just use:

script.Parent.Image = tostring(content)
3 Likes

Thanks, it worked!

Ah, sorry to bother you but, I just tested it in game and it’s giving everyone the same picture as me. Any way to fix that?

The script is a local script located somewhere on the player, right? It shouldn’t always be a picture of you since it’s using the local player’s userid.

1 Like

It’s a local script, yes. Inside the player ui

image

And for some reason I am getting that glitch. Is it because of the filtering enabled?

I doubt it’s because of FE. If you haven’t changed the two lines which I gave you, it should work fine. Unless you’re making a leaderboard and you’re saying that every player has your character, then it’d make sense why. Instead of having a local script as the child of the imagelabel and having it set the image to a headshot of the local player, you would need to integrate those two lines into the script (LeaderboardMaster) that deals with listing the players for the gui.

1 Like