How to make player avatar and name show on part?

Hi,

So I made a team and a part that puts players in that team when they touch it, but now my goal is to make that if the player is in that team their face and name show up on a part.

I’m not too sure how this is achieved. Any help is very much appreciated.

So far I have this:

image
image

local team = game.Teams:FindFirstChild("Caretaker")
local displayPart = script.Parent
local surfaceGui = displayPart:WaitForChild("SurfaceGui")
local imageLabel = surfaceGui:WaitForChild("ImageLabel")
local textLabel = surfaceGui:WaitForChild("TextLabel")

local function updateDisplay()
	-- Find a player in the team
	for _, player in ipairs(game.Players:GetPlayers()) do
		if player.Team == team then
			-- Set the image to player's face
			imageLabel.Image = "rbxthumb://type=AvatarHeadShot&id=" .. player.UserId .. "&w=150&h=150"

			-- Set the text to the player's name
			textLabel.Text = player.Name

			-- Update the visibility
			imageLabel.Visible = true
			textLabel.Visible = true

			return
		end
	end

	imageLabel.Visible = false
	textLabel.Visible = false
end

-- Update the display every 1 sec
while true do
	updateDisplay()
	wait(1)
end

1 Like

BillboardGui can do this.You can create a BillBoardGui in the part.

1 Like

Isn’t it supposed to be surfacegui because it needs to show on the part and not above.