Why does my nametag GUI not change to 'CLASSIFIED' username?

Here is part of my code that is supposed to change your username to ‘CLASSIFIED’ under the Gui.

local Gui = game.ServerStorage:WaitForChild("Name Tag Gui")

local CustomNickNames = { -- MTF
	[525987873] = 'O5-1',
	[138340676] = 'ATLAS', -- ChinasGovernment
	[414648457] = 'SPECTRE', -- ApolloZenith
	[1114489944] = 'EAGLE' -- RealMrTaylor
}

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local NewGui = Gui:Clone()
		local Information = NewGui:WaitForChild("Information")
		local UserRank = Information.UserRank
		local UserName = Information.UserName
		UserRank.Text = Player:GetRoleInGroup(game.Teams:WaitForChild(Player.Team.Name).GroupId.Value)
		UserName.Text = Player.Name
		NewGui.Parent = Character.Head
		
		Character:WaitForChild("Humanoid").DisplayDistanceType = "None"
		
		local All = Information:GetChildren()
		for A = 1,#All do
			All[A].TextColor3 = Player.TeamColor.Color
		end
		
		if Player.Team == game.Teams:WaitForChild("Mobile Task Force") then
			if CustomNickNames[Player.UserId] ~= nil then
				UserName = CustomNickNames[Player.UserId]
				
			elseif Player.Team == game.Teams:WaitForChild('Intelligence Agency') then
				if Player.UserId == 00000000 then
					UserName.Text = 'O5-5'
				else
					UserName.Text = 'CLASSIFIED'
				end

That is because you are not writing it in the correct area. There is no end after this code block:

Meaning that it will do the following:

  • Check if the user is on MTF
  • If the user is on MTF, it will check if they do not have a custom nick name
  • If they do not have a custom nick name, if will check if they are on IA

Try this and see if it fixes the issue:

if Player.Team == game.Teams:WaitForChild("Mobile Task Force") then
			if CustomNickNames[Player.UserId] ~= nil then
				UserName = CustomNickNames[Player.UserId]
                        end
elseif Player.Team == game.Teams:WaitForChild('Intelligence Agency') then
	if Player.UserId == 00000000 then
		UserName.Text = 'O5-5'
	else
		UserName.Text = 'CLASSIFIED'
	end
end