Overhead GUI not updating correctly

I want the color of the player’s name to update accordingly to their TeamColor.
The TeamColor never changes when the player’s team is changed.
I’ve tried getting answers from the DevForum, this post, but only one person responded and was never fixed.

Overhead Code (Server Script, ServerScriptService)
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:WaitForChild("Head")
		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
		
		clone.Frame.NameTag.Name1.TextColor3 = player.TeamColor.Color
		player.Team.Changed:Connect(function()
			clone.Frame.NameTag.Name1.TextColor3 = player.TeamColor.Color
		end)
		clone.Parent = head
	end)
end)
Team Changer Code, StarterGui.Teams, LocalScript
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)

SCROLLER1_SCROLLINGFRAME.Blue.MouseButton1Click:Connect(function()
	if Player:IsInGroup(Gids.Bdd) then
		Funcs.SetTeam(Player,game.Teams["Blue Diamond Development"])
	end
end)
'Funcs' Code, ReplicatedStorage, ModuleScript
local Funcs = {
	GetRank = function(group,user)
		return user:GetRankInGroup(group)
	end,
	GetRole = function(group,user)
		return user:GetRoleInGroup(group)
	end,
	
	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

I don’t think you can Set Team on Client-Side,
Try Set Team on Server-Side

The teaming works, it sets the team perfectly fine; it’s the overhead that doesn’t update.

Color of the player name in the game or the leaderboard?

  1. No, setting the team on the client side does in fact not work. It only updates for the client, and gui is visually coded on the client, so it “looks” like the team is changing.
  2. You are detecting changes in the Player’s Team (the actual Team Instance), not the Team property of the Player.
player:GetPropertyChangedSignal("Team"):Connect(function()
    -- code
end)
  1. As a heads up, you cannot kick other players on the client, meaning you cannot call Funcs.Kick without communicating to the server via remotes.

Thank you, this works now.

I set the Funcs.SetTeam to use a remote to communicate with the server and allowing the server to change the user’s team to the team provided.

Side Note: I also changed the Funcs.Kick as well.

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