Why wont this image of player load into image label?

Why wont the player picture load? the imagelabel image is set however the iamge doesnt actually show? am i doing something wrong?

local RepStorage = game:GetService("ReplicatedStorage")
local GPEvent = RepStorage:WaitForChild("Events").GamePlay.GameStart
local Gameend = RepStorage:WaitForChild("Events").GamePlay.GameEnd
local GameMessageModule = require(game.ReplicatedStorage:WaitForChild("Modules").GameMessageModule)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local ui = player.PlayerGui
local PlayerDataUI = ui:WaitForChild("PlayerData"):WaitForChild("Frame")

local gamestarttext = PlayerDataUI.GameStart.TextLabel
local gamestarttextstroke = PlayerDataUI.GameStart["TextLabel-stroke"]

local Players = game:GetService("Players")
local BoatsFolder = workspace:WaitForChild("Boats")



local function applyBoatPhoto(boat)
	task.wait(5)
	local identValue = boat:FindFirstChild("Ident")

	local playerName = identValue.Value
	local player = Players:FindFirstChild(playerName)
	if not player then return end

	-- Get player UserId
	local userId = player.UserId

	-- Apply the image to the boat's ImageLabel
	local imageLabel = boat:FindFirstChild("Data").BillboardGuiPhoto.Frame.ImageLabel
	
	imageLabel.Image = Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size100x100)
	
end

-- Setup: run for existing boats…
for _, boat in ipairs(BoatsFolder:GetChildren()) do
	applyBoatPhoto(boat)
end

-- …and any future ones
BoatsFolder.ChildAdded:Connect(applyBoatPhoto)

Perhaps the second value returned by the GetUserThumbnailAsync() function is false. Try repeating it until the second value is true.

local content, isReady
repeat
    content, isReady = Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size100x100)
until content ~= nil and isReady == true

imageLabel.Image = content

I wouldn’t recommend a repeat until as GetUserThumbnailAsync will eventually return 429 (RateLimit) then your just stuck in a endless cycle of trying to get the Thumbnail.

Perhaps implement a task.wait & Cache the Thumbnail/PFP for future use so you don’t have to call it as much.

1 Like