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

Trying to get a thumbnail head shot of the player from a server script but it's not working?

So, I want to get an image label which is a head shot of the player, I have done this in a local script before but when I tried to move over the code and made some changes would make sense, it doesn't work and still shows a blank picture. I have done everything with creating the imageLabel etc, but there is one line of code which doesn't seem to be working the way I expected it to.

Code:

--there is some code before this, but it is unneeded.
	local UserId = player.UserId
	local thumbType = Enum.ThumbnailType.HeadShot
	local thumbSize = Enum.ThumbnailSize.Size100x100
	game.Players.PlayerAdded:Connect(function(players)
		local content, isReady = players:GetUserThumbnailAsync(UserId, thumbType, thumbSize) -- this is where the problem is, this is what I can't figure out is the players should come from.
		newImage.Image = content
	end)
end

remoteEventLocalPhoto.OnServerEvent:Connect(playerPhoto)

2 answers

✓ Accepted answer

Problem solved, I don't get how I didn't understand the problem in the first place. I could simply just use the service of players instead of getting them in any other way. Here is my updated code.

Code:

	local UserId = player.UserId
	local thumbType = Enum.ThumbnailType.HeadShot
	local thumbSize = Enum.ThumbnailSize.Size100x100
	local players = game:GetService("Players") -- This was the line I changed.
	local content, isReady = players:GetUserThumbnailAsync(UserId, thumbType, thumbSize)
	newImage.Image = content
end

remoteEventLocalPhoto.OnServerEvent:Connect(playerPhoto)

1 comment

0

cheers, glad you got your answe

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