Player photo not showing on imagelabel?

Am i doing something wrong on this local script? its always not ready when trying to process the picture. and even if i take that check away, it shows no image in the image url?


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 function setBoatPhotos()
	task.wait(5)
	for _, boat in ipairs(workspace.Boats:GetChildren()) do
		local identValue = boat:FindFirstChild("Ident", true)
		if identValue then
			local Players = game:GetService("Players")

			local playerName = identValue.Value
			local matchedPlayer = Players:FindFirstChild(playerName)
			local headshot

			if matchedPlayer then
				local userId = matchedPlayer.UserId


				local function getHeadshot(userId)
					local thumbUrl, isReady = Players:GetUserThumbnailAsync(
						userId,
						Enum.ThumbnailType.HeadShot,
						Enum.ThumbnailSize.Size100x100
					)

					if isReady then
						return thumbUrl
					else
						warn("Thumbnail not ready")
						return nil
					end
				end

				local imageLabel = boat:FindFirstChild("Data", true)
					and boat.Data:FindFirstChild("BillboardGuiPhoto", true)
					and boat.Data.BillboardGuiPhoto:FindFirstChild("Frame", true)
					and boat.Data.BillboardGuiPhoto.Frame:FindFirstChild("ImageLabel", true)

				local headshot = getHeadshot(userId)
				if headshot and imageLabel then
					imageLabel.Image = headshot
				end

			else
				warn("❌ Player not found for Ident:", playerName)
			end
		end
	end
end






GPEvent.OnClientEvent:Connect(function(i)
	
	if i == "Nil" then
		PlayerDataUI.GameStart.Visible = true
		gamestarttext.Text = "Wait for 2 players to start... "
		gamestarttextstroke.Text = "Wait for 2 players to start... "
		return
	end
	PlayerDataUI.GameStart.Visible = true
	gamestarttext.Text = "Game starting in... "..tostring(i)
	gamestarttextstroke.Text = "Game starting in... "..tostring(i)
	
	if i == 0 then
		gamestarttext.Text = "Starting..."
		gamestarttextstroke.Text = "Starting..." 
		task.wait(3)
		PlayerDataUI.GameStart.Visible = false
		PlayerDataUI.GameDropDown.Visible = true
		PlayerDataUI.BoatHealth.Visible = true
		setBoatPhotos()	
	end
	

end)

You could either be:

  • Ratelimiting the api due to many getHeadshot requests?
  • Allow HTTP Requests is turned off in your game Security tab
1 Like