Overhead GUI not updating accordingly

I wish my overheadgui to display the player’s team via TextColor3 inside their username label.
The player’s overhead will not updater the TextColor3 at all when I switch teams. It only works if I use Adonis to switch teams.

I have looked on the DeveloperForum but nothing was relevant to the issue nor provided any help.

Overhead Code

local playersadded = game.Players.PlayerAdded
local overhead = script.Rank

playersadded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local clone = overhead:Clone()
		local head = char:FindFirstChild("Head")
		if not head then repeat wait() until head end
		local namelen = player.Name:len()
		
		if namelen < 15 then
			clone.Frame.NameTag.Name1.Text = player.Name
		elseif namelen > 15 then
			clone.Frame.NameTag.Name1.Text = string.sub(player.Name,1,15)..".."
		end
		local role = player:GetRoleInGroup(5227543)
		
		local r = player:GetRankInGroup(5227543)
		if r == 106 or r >= 127 then
			clone.Frame.RankTag.Rank.Text = role:sub(2,role:len())
		end
		if r >= 92 and r < 101 then
			clone.Frame.Tag.Tag.Text = "Fort Diego Officer"
		elseif r >= 102 and r <= 105 then
			clone.Frame.Tag.Tag.Text = "United States High Ranking"
		elseif r == 106 then
			clone.Frame.Tag.Tag.Text = "VIP"
		elseif r == 107 or r == 108 then
			clone.Frame.Tag.Tag.Text = "President's Office"
		elseif r == 125 or r == 126 then
			clone.Frame.Tag.Tag.Text = "Commanding Officer"
		elseif r == 127 then
			clone.Frame.Tag.Tag.Text = "Fort Diego Lifted Perms"
		elseif r == 253 or r == 254 then
			clone.Frame.Tag.Tag.Text = "BDD Executive Team"
		elseif r == 255 then
			clone.Frame.Tag.Tag.Text = "Ownership"
		end
		
		if player:GetAttributeChangedSignal("Team") and player:GetAttributeChangedSignal("TeamColor") then
			clone.Frame.NameTag.Name1.TextColor3 = player.TeamColor.Color
		end
		
		clone.Parent = head
	end)
end)
Team Changer
"Handler" code
local Gids = require(game.ReplicatedStorage.GroupIds)
local Funcs = require(game.ReplicatedStorage.Funcs)
local Player = game.Players.LocalPlayer

local TEAMS_SCREENGUI = script.Parent
local SCREEN_FRAME = TEAMS_SCREENGUI.Screen
local SWITCH_TEXTBUTTON = SCREEN_FRAME.Switch_Button
local TEAMS_TEXTBUTTON = TEAMS_SCREENGUI.Teams_Button
local SCROLLER1_SCROLLINGFRAME = SCREEN_FRAME.Scroller1
local SCROLLER2_SCROLLINGFRAME = SCREEN_FRAME.Scroller2

TEAMS_TEXTBUTTON.MouseButton1Click:Connect(function()
	SCREEN_FRAME.Visible = not SCREEN_FRAME.Visible
	task.wait(.1)
	if SCREEN_FRAME.Visible == false then
		TEAMS_TEXTBUTTON.Text = "Teams"
	elseif SCREEN_FRAME.Visible == true then
		TEAMS_TEXTBUTTON.Text = "Close"
	end
end)


SCROLLER1_SCROLLINGFRAME.Civilian.MouseButton1Click:Connect(function()
	Funcs.SetTeam(Player,game.Teams.Civilian)
end)

SCROLLER1_SCROLLINGFRAME.Personnel.MouseButton1Click:Connect(function()
	if Player:IsInGroup(Gids.Fd) then
		Funcs.SetTeam(Player,game.Teams["Diego Personnel"])
	end
end)

SCROLLER1_SCROLLINGFRAME.Cabinet.MouseButton1Click:Connect(function()
	if Funcs.GetRank(Gids.Fd,Player) >= 107 then
		Funcs.SetTeam(Player,game.Teams["Cabinet Personnel"])
	end
end)

SCROLLER1_SCROLLINGFRAME.Headquarters.MouseButton1Click:Connect(function()
	if Player:GetRankInGroup(Gids.Fd) >= 125 then
		Funcs.SetTeam(Player,game.Teams.Headquarters)
	end
end)

SCROLLER1_SCROLLINGFRAME.National.MouseButton1Click:Connect(function()
	if Player:IsInGroup(Gids.Ng) then
		Funcs.SetTeam(Player,game.Teams["National Guard"])
	end
end)

SCROLLER1_SCROLLINGFRAME.Training.MouseButton1Click:Connect(function()
	if Player:IsInGroup(Gids.Tdc) then
		Funcs.SetTeam(Player,game.Teams["Training and Doctrine Command"])
	end
end)

SCROLLER1_SCROLLINGFRAME.Special.MouseButton1Click:Connect(function()
	if Player:IsInGroup(Gids.Sf) then
		Funcs.SetTeam(Player,game.Teams["Special Forces"])
	end
end)

SCROLLER2_SCROLLINGFRAME.Blue.MouseButton1Click:Connect(function()
	if Player:IsInGroup(Gids.Bdd) then
		Funcs.SetTeam(Player,game.Teams["Blue Diamond Development"])
	end
end)
"Funcs" code
local Funcs = {
	GetPlayers = function ()
		return game.Players:GetPlayers()
	end,
	Kick = function(User,Reason)
		User:Kick("The system has kicked you from the game!\nReason: "..Reason)
	end,
	SetTeam = function(User,Team)
		if Team and User then
			User.Team = game.Teams:FindFirstChild(Team.Name)
			game.ReplicatedStorage.Remotes["Load Character"]:FireServer()
		end
	end,
}

return Funcs
"Gids" code
local Ids = {
	Fd = 5227543,
	Ng = 17401593,
	Sf = 17401606,
	Hq = 5227543,
	Bdd = 16288913,
	Cabinet = 5227543,
	Tdc = 17385326,
}


return Ids
Images

image
.
image

I’m afraid you don’t understand how events work. It’s not possible to check events like this, and I’m pretty sure it’s not necessary, as Team and TeamColor both change at the same time.

Try this code.

player:GetAttributeChangedSignal("Team"):Connect(function()
    clone.Frame.NameTag.Name1.TextColor3 = player.TeamColor.Color
end)
1 Like

Now it isn’t changing whatsoever.

There’s a lot of things I could pick at but I think this is your problem, instead of using :FindFirstChild() and then polling for it (which will never return), simply use :WaitForChild().

local head = char:WaitForChild("Head")

Polling is never a good practice (repeat + wait for something)

Still not changing even with the code you provided (player:GetAttributeChangedSignal("Team"):Connect(function() clone.Frame.NameTag.Name1.TextColor3 = player.TeamColor.Color end)) and the code I previously had.

This is also a bit weird, you shouldn’t put events in variables, they aren’t going anywhere.

Try this:

game.Players.PlayerAdded:Connect(function(player)
...

Also, add some print statements, make sure everything is running.

I don’t understand how putting an event inside a variable would make the script break, everything is running fine besides that one specific line.