How do I make an overhead GUI that shows the players username and team?

Hi! I am currently working on a training center for my bakery group, and I want to create an overhead GUI that shows the players username and the name of the team that they are on. For example, if I was on the “Group A” team, then above my head it would show my username and “Group A” below it.

I have found many people dealing with the same issue, but every time I follow the solutions in the replies they never end up working for me.

I also have little experience with scripting and GUI, so this is all very new to me. If anyone can help me, that would be great!

2 Likes

is “Group A” related to a Roblox Group role?

1 Like

No, “Group A” would be one of the teams.

function setPos(character)
	local sizeY = character.Head.Size.Y
	for i,v in pairs(character:GetChildren()) do
		if v:IsA("Accessory") then
			local mainPart = v:FindFirstChildWhichIsA("BasePart")
			local comp = mainPart.Position.Y > character.Head.Position.Y
			if comp == true then
				sizeY += mainPart.Size.Y
			else
				continue
			end
		else
			continue
		end
	end
	return sizeY
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(character)
		local billboardgui = Instance.new("BillboardGui")
		billboardgui.MaxDistance = 50
		billboardgui.AlwaysOnTop = false 
		billboardgui.Size = UDim2.new(4,0,1,0)
		local NameLabel = Instance.new("TextLabel")	
		NameLabel.Size = UDim2.new(1,0,0.5,0)
		NameLabel.TextScaled = true
		NameLabel.Text = player.Name
		NameLabel.TextColor3 = Color3.fromRGB(255,255,255)
		NameLabel.TextStrokeTransparency = 0
		NameLabel.BackgroundTransparency = 0
		NameLabel.BackgroundColor3 = Color3.fromRGB(163,162,165)
		NameLabel.Parent = billboardgui
		local TeamLabel = Instance.new("TextLabel")
		TeamLabel.Size = UDim2.new(1,0,0.5,0)
		TeamLabel.Position = UDim2.new(0,0,0.5,0)
		TeamLabel.TextScaled = true
		TeamLabel.Text = player.Team.Name
		TeamLabel.TextColor3 = Color3.fromRGB(255,255,255)
		TeamLabel.TextStrokeTransparency = 0
		TeamLabel.BackgroundTransparency = 0
		TeamLabel.BackgroundColor3 = Color3.fromRGB(163,162,165)
		TeamLabel.Parent = billboardgui
		billboardgui.ExtentsOffset = Vector3.new(0,setPos(character) + billboardgui.Size.Y.Scale,0)
		billboardgui.Parent = character.Head
	end)
end)

try this.

image

2 Likes

You can simply create a BillboardGui, and upon a Character being added (player.CharacterAdded), set the cloned BillboardGui’s Adornee to the player’s head.

Then, you can simply set the BillboardGui’s TextLabel which would be set to “Name”, to the player’s name, and vice versa for the Team.

The BillboardGui would be set up like this:

BillboardGui
   Username (TextLabel)
   Team (TextLabel)
local BillboardGui = ...
Player.CharacterAdded:Connect(function(Character)
   local clonedGui = BillboardGui:Clone()
   clonedGui.Parent = Character
   clonedGui.Adornee = Character.Head
   --set instance propert(ies) here
end)

Thank you, it worked. How would I change the font?

NameLabel.Font = Enum.Font.SourceSans
TeamLabel.Font = Enum.Font.SourceSans

When I change the font it shows up really far above my head. Then every time I change the position it disappears.

which font is causing the error?

I used Source Sans Bold, should I try using something else?

Can you send a screenshot of the error? Like the picture below

image

Is it because I removed the background?

1 Like
function setPos(character)
	local sizeY = character.Head.Size.Y
	for i,v in pairs(character:GetChildren()) do
		if v:IsA("Accessory") then
			local mainPart = v:FindFirstChildWhichIsA("BasePart")
			local comp = (mainPart.Size.Y/2)+mainPart.Position.Y > (character.Head.Size.Y/2 + character.Head.Position.Y)
			if comp == true then
				sizeY += (mainPart.Size.Y/2+mainPart.Position.Y) - (character.Head.Size.Y/2 + character.Head.Position.Y)
			else
				continue
			end
		else
			continue
		end
	end
	
	return sizeY
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(character)
		if character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
			local billboardgui = Instance.new("BillboardGui")
			billboardgui.MaxDistance = 50
			billboardgui.AlwaysOnTop = false 
			billboardgui.Size = UDim2.new(4,0,1,0)
			local NameLabel = Instance.new("TextLabel")	
			NameLabel.Size = UDim2.new(1,0,0.5,0)
			NameLabel.TextScaled = true
			NameLabel.Text = player.Name
			NameLabel.TextColor3 = Color3.fromRGB(255,255,255)
			NameLabel.TextStrokeTransparency = 0
			NameLabel.BackgroundTransparency = 0
			NameLabel.BackgroundColor3 = Color3.fromRGB(163,162,165)
			NameLabel.Parent = billboardgui
			NameLabel.Font = Enum.Font.SourceSansBold
			local TeamLabel = Instance.new("TextLabel")
			TeamLabel.Size = UDim2.new(1,0,0.5,0)
			TeamLabel.Position = UDim2.new(0,0,0.5,0)
			TeamLabel.TextScaled = true
			TeamLabel.Text = player.Team.Name
			TeamLabel.TextColor3 = Color3.fromRGB(255,255,255)
			TeamLabel.TextStrokeTransparency = 0
			TeamLabel.BackgroundTransparency = 0
			TeamLabel.BackgroundColor3 = Color3.fromRGB(163,162,165)
			TeamLabel.Parent = billboardgui
			TeamLabel.Font = Enum.Font.SourceSansBold
			billboardgui.ExtentsOffset = Vector3.new(0,setPos(character) + billboardgui.Size.Y.Scale,0)
			billboardgui.Parent = character.Head
		else
			character.ChildAdded:Connect(function(part)
				if not character.Head:FindFirstChildWhichIsA("BillboardGui") then
					local billboardgui = Instance.new("BillboardGui")
					billboardgui.MaxDistance = 50
					billboardgui.AlwaysOnTop = false 
					billboardgui.Size = UDim2.new(4,0,1,0)
					local NameLabel = Instance.new("TextLabel")	
					NameLabel.Size = UDim2.new(1,0,0.5,0)
					NameLabel.TextScaled = true
					NameLabel.Text = player.Name
					NameLabel.TextColor3 = Color3.fromRGB(255,255,255)
					NameLabel.TextStrokeTransparency = 0
					NameLabel.BackgroundTransparency = 0
					NameLabel.BackgroundColor3 = Color3.fromRGB(163,162,165)
					NameLabel.Parent = billboardgui
					NameLabel.Font = Enum.Font.SourceSansBold
					local TeamLabel = Instance.new("TextLabel")
					TeamLabel.Size = UDim2.new(1,0,0.5,0)
					TeamLabel.Position = UDim2.new(0,0,0.5,0)
					TeamLabel.TextScaled = true
					TeamLabel.Text = player.Team.Name
					TeamLabel.TextColor3 = Color3.fromRGB(255,255,255)
					TeamLabel.TextStrokeTransparency = 0
					TeamLabel.BackgroundTransparency = 0
					TeamLabel.BackgroundColor3 = Color3.fromRGB(163,162,165)
					TeamLabel.Parent = billboardgui
					TeamLabel.Font = Enum.Font.SourceSansBold
					billboardgui.ExtentsOffset = Vector3.new(0,setPos(character) + billboardgui.Size.Y.Scale,0)
					billboardgui.Parent = character.Head
				end
			end)
		end
	end)
end)

You can simply insert your own BillboardGui into the script you are currently using, clone it into the player’s PlayerGui when they join, and set the Adornee to their head.

Edit: This is much simpler than using a script to create the BillboardGui and allows for more customization.

Hi, I just need to say thank you for this script. Since i used this script, they started using it for their own games!

Unfortunately, i’m stuck when changing teams, i need to refresh using the Admin Commands.