How to get player profile image on a SurfaceGui?

I’m trying to put the local player’s Roblox profile picture on a SurfaceGui. Though, it seems to be very different from putting it on a GUI. I’m not quite sure where to start but this is just a non-functional code example of what I’m trying to do:

local thumb = game:GetService("Players"):GetUserThumbnailAsync(game:WaitForChild("Players").LocalPlayer.UserId)
script.Parent.Image = thumb 

Let me know if you have any questions. Thanks!

Note:
I’m a builder, not a scripter. I’d love to hear explanations on how these things work as I’m trying to learn! (if possible) Thanks!

1 Like

This Post might Interest you:

And a Video:

I’m trying to put it on a SurfaceGui. It seems to be different for a Surface Gui as opposed to a regular GUI.

Do you mean as in, you cant Use LocalScripts?

No, it’s a local script. However, I’ve tried these exact scripts many times and none of them have functioned except for when I’ve used them to create a ScreenGui.

It doesnt work if you try something like this?

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

local thumb = Players:GetUserThumbnailAsync(Player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)

if thumb then
game.Workspace:WaitForChild("PartWithSurface"):WaitForChild("SurfaceGui"):WaitForChild("ImageLabel").Image = thumb
end

But, I think the approach would depend on whats the purpose for this, like, each player has its own surface gui? why showing the player picture on that part? is a winner of something?

1 Like

It’s a single-player game. I’m just trying to show the player’s face on a poster.

If its a LocalScript

Make sure it isn’t inside the workspace, as LocalScripts do not normally work in the workspace if you want to use LocalScripts within the workspace, I recommend looking into RunContext. (it wont Direct to the Proper Method)

Put the SurfaceGui inside StarterGui, and Adorne (NOT PARENT), the UI to the Part, then you can use LocalScripts

The code I gave you works good for me, if its a single player game

The poster is in Workspace, that makes no difference, the script is in StarterScripts and its a local script of course

Sorry, Cairo’s is the first one I tried that worked. Thanks you all so much for your help! I learned a lot.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.