How would i use GetUserThumbnailAsync for a roblox horror lobby?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’d like to display players that have been teleported into the queue with a timer that teleports them to the main game on the teleporter itself

  2. What is the issue? Include screenshots / videos if possible!
    When i enter the teleporter it fills both images now i know this is because the for loop but i don’t know of any other method to get a folders children and then fill them and i don’t know how to fill them in order like if player 1 gets displayed for the code to see that and skip over player 1 and display player 2, i guess that’s where my issue lies.
    image

this is what i’d like to achieve :

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    For now none, i have searched but have found nothing.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote2 = ReplicatedStorage:WaitForChild("Remotes"):FindFirstChild("LeaveLobby")
local TouchPart = workspace:FindFirstChild("TwoPlayersTest")
local PlayerImages = TouchPart.PlayerCount.PlayerImages
local Players = game:GetService("Players")


TouchPart.Touched:Connect(function(hit)

	if hit.Parent:FindFirstChild("Humanoid") then

		local PLACEHOLDER_IMAGE = "rbxassetid://0" 
		local userId = Players:GetPlayerFromCharacter(hit.Parent).UserId
		local thumbType = Enum.ThumbnailType.HeadShot
		local thumbSize = Enum.ThumbnailSize.Size60x60
		local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
		
		for _,v in pairs(PlayerImages:GetChildren())  do
			
			  v.Image = (isReady and content) or PLACEHOLDER_IMAGE
			  
			if v.Image == PLACEHOLDER_IMAGE then
				
			print("Image is a placeholder")
		else	
			print("Image is displaying a player")
			end
		end
	end
end)


Remote2.OnServerEvent:Connect(function()
	for _, v in pairs(PlayerImages:GetChildren()) do
		v.Image = "rbxassetid://0"
	end
end)

local characters = {} 
Players.PlayerAdded:Connect(function(player)
	player.CharacterRemoving:Connect(function(character)
		characters[player] = character
	end)
end)

Players.PlayerRemoving:Connect(function(player)
	local character = characters[player]
	characters[player] = nil 
end)

Thanks for the help in advance!

1 Like

If there are 2 images. then I would rely on a variable. Basically:

local used = {false, false} -- Added the "used" list


TouchPart.Touched:Connect(function(hit)

	if hit.Parent:FindFirstChild("Humanoid") then

		local PLACEHOLDER_IMAGE = "rbxassetid://0" 
		local userId = Players:GetPlayerFromCharacter(hit.Parent).UserId
		local thumbType = Enum.ThumbnailType.HeadShot
		local thumbSize = Enum.ThumbnailSize.Size60x60
		local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)

		for i,v in pairs(PlayerImages:GetChildren())  do

			v.Image = (isReady and content) or PLACEHOLDER_IMAGE

			if not used[i] then -- Refrence the variable to check if it is used or not.

				print("Image is a placeholder")
				-- used[i] = true -- Set the variable to true as it is now used.
				break
			else	
				print("Image is displaying a player")
			end
		end
	end
end)

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