Overlapping Gui

  1. What do you want to achieve? A overhead Gui that displays your team

  2. What is the issue? The Gui’s are overlapping, one shows the name, the other is a blank gui that says “Label” meaning it has just been cloned which is what I want to prevent. In other words I want only 1 gui thats it.

  3. What solutions have you tried so far? Editing the code

local BillboardGUI = game.ReplicatedStorage.BillboardGui

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local head = char.Head
		local OverheadGUI = BillboardGUI:Clone()
		local text = OverheadGUI.TextLabel
		OverheadGUI.Parent = char.Head
		OverheadGUI.Adornee = char.Head

		local function MilitaryPolice()
			text.TextColor3 = Color3.fromRGB(255, 255, 255)
			text.Text = "Military Police"
			text.Name = "A"
		end
		if player.Team == game.Teams.MilitaryPolice then
			text.Text = "Military Police"
			if player.Team ~= game.Teams.MilitaryPolice then
				game.LocalPlayer.Head.A:Destroy()
				
			end
		end
	end)
end)
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local head = char.Head
		local OverheadGUI = BillboardGUI:Clone()
		local text = OverheadGUI.TextLabel
		OverheadGUI.Parent = char.Head
		OverheadGUI.Adornee = char.Head

		local function SpecialForces()
			text.TextColor3 = Color3.fromRGB(255, 255, 255)
			text.Text = "Special Forces"
			text.Name = "B"
		end
		if player.Team == game.Teams.SpecialForces then
			text.Text = "Special Forces"
			if player.Team ~= game.Teams.SpecialForces then
				game.LocalPlayer.Head.B:Destroy()
			end
		end
	end)
end)

You first off need to offset the name GUI. Second, use TeamColor and all that because it’s better and more reliable.

What does this mean? @CommanderRanking

I also don’t want to use team color, its supposed to be black

This would take place in the properties tab. You need to set the positioning to above the 2nd UI, or flip flop, whichever you’d like. Second, just use TeamColor like this instead of if Player.Team and all that:

if player.TeamColor = BrickColor.new("") then -- Add BrickColor in the quotation marks.
1 Like

I tried using an if statement to delete a gui that read “Label but it didn’t work”

See? and This still doesn’t work any suggestions @CommanderRanking

Didn’t I answer this in a previous post?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local BillboardGUI = ReplicatedStorage:WaitForChild("BillboardGui")

function PlayerAdded(player) 
	local function update(char)
		if not char then return end 
		local head = char:WaitForChild("Head", 5) 
		if not head then return end 
		local UI = head:FindFirstChild(BillboardGUI.Name) 
		if not UI or not UI:FindFirstChild("TextLabel") then 
			UI = BillboardGUI:Clone() 
			UI.Parent = head 
			UI.Adornee = head 
		end	
		local text = UI.TextLabel 	
		local team = player.Team 
		if team then 
			team = team.Name 
		else 
			team = "None"
		end
		text.Text = team 
	end
	update(player.Character or player.CharacterAdded:Wait()) 
	player.CharacterAdded:Connect(update)
	player:GetPropertyChangedSignal("Team"):Connect(function()
		update(player.Character)
	end)
end

for i, player in pairs(Players:GetPlayers()) do 
	PlayerAdded(player)
end
Players.PlayerAdded:Connect(PlayerAdded)

1 Like