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

How do you get a Headshot image of a player?

Hello,

So when I am running this function. The script is supposed to get a random player's headshot. Should be quite simple, although this is my first timing using player-images, and it doesn't seem to work! I'm not sure what I am doing wrong.

This is my script, everything works fine when running the function, but the image won't load, Why does the request fail?

function PlayerTextAni()
	local p = Players:GetPlayers()
	local selected_value = math.random(1,#p)
	local UserId = p[selected_value].Name
	local GuiType = PlayerText
	local GuiText = Text
	GuiType.Frame.Player.Image = "https://www.roblox.com/headshot-thumbnail/image?username="..(UserId).."48103520&width=420&height=420&format=png"
	GuiType.Frame.Visible = true
	for i = 1, #GuiText do
		GuiType.Frame.Frame.Text.Text = string.sub(GuiText, 1, i)
		TextSound:Play()
		wait(0.05)
	end
	wait(2)
	GuiType.Frame.Frame.Text.Text = ""
	GuiType.Frame.Visible = false
end

Thanks for helping, Simon.

1 answer

✓ Accepted answer

Don't use a link. Use GetUserThumbnailAsync.

Example:

local imageLabel = script.Parent
local player = game.Players.LocalPlayer
local players = game.Players:GetPlayers()

local thumbnailType = Enum.ThumbnailType.HeadShot
local thumbnailSize = Enum.ThumbnailSize.Size420x420

local content, isReady = players:GetUserThumbnailAsync(player.UserId, thumbnailType, thumbnailSize)

imageLabel.Image = content

As long as the script is a local script you're all good to go.

2 comments

0

Thank you very much!

0

Np

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