How to put a player profile picture on a part

Hello Developers, how to put a player profile picture on a part and I choose the player in the script like example (put @roblox profile picture on script parent) if anyone know how can you tell me how and write a script if you can?

11 Likes

I’m not sure if I know what you mean. Try looking at this: How to get Profile Icon? - #8 by OverEngineeredCode

Players:GetUserThumbnailAsync

Give this a look over. You can use this function in conjunction with a BillboardGui to display Profile Pictures on Parts.

No like I want the script to put a player profile picture and I just type the player username like local player = @playerusername

3 Likes

I don’t understand, could you be more specific?

Ok so to do so First make a part with image label like this:


Then Make A Gui Like this with TextBox:

You can change the properties like you want but for reference do this:

Then a Local Script inside StarterPlayerScripts:
Screenshot_12
and At last script like this:

local Player = game.Players.LocalPlayer

local Gui = Player.PlayerGui:WaitForChild("ScreenGui")

Gui.TextBox.FocusLost:Connect(function(OnEnter)
	if not OnEnter then return end
	local PlayerUserId = game.Players:GetUserIdFromNameAsync(Gui.TextBox.Text)
	if not PlayerUserId then return end
	local Image
	local success, errormsg = pcall(function()
		Image = game.Players:GetUserThumbnailAsync(PlayerUserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
	end)
	if not success then
		warn(errormsg)
		return
	end
	if Image then
		game.Workspace.Part.SurfaceGui.ImageLabel.Image = Image
	end
end)

Result:


Mark Me Solution Please :slight_smile:

4 Likes

sorry but I want to type the player username not the player type his username I want to type it in the script not in ui sorry.

3 Likes

well thats easy too
make a script in workspace and inside the script do this:

local PlayerUserName = "i6Hx" -- Put The Username Here

local PlayerUserId = game.Players:GetUserIdFromNameAsync(PlayerUserName)
if not PlayerUserId then return end
local Image
local success, errormsg = pcall(function()
	Image = game.Players:GetUserThumbnailAsync(PlayerUserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
end)
if not success then
	warn(errormsg)
	return
end
if Image then
	game.Workspace.Part.SurfaceGui.ImageLabel.Image = Image
end

Done

5 Likes

Btw Change the Enum.ThumbnailType to whatever u want so like for Ex:
if u want head shot then put Enum.ThumbnailType.HeadShot.

4 Likes

Alright I’m gonna test it thank you for help.

3 Likes

Download his profile picture and put it on the image label

2 Likes

@fasmandom
where should I put the script like this?
image
or like this?
image

3 Likes

I did it first but I want the image to change when the player changes his avatar

3 Likes

just simply put in workspace
like this:
Screenshot_1

1 Like

But! how the script will know my part surface gui

2 Likes

This is the way so he find it change the instances to the names from the path

1 Like

@fasmandom can this script be used for Guis in starter Gui I can use this for credits and loading screen

I edited some stuff in it to put it in the script children and it works thank you so much for help!! :sparkling_heart::sparkling_heart::sparkling_heart:

2 Likes

Well u gotta change it to a local script and make a few changes but it should work
u could tween it as well

1 Like

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