How to make a nametags for every division group?

So I own a SCPF and I am making a game for it, and I got to the point I needed to add nametags for it.

So I tried but failed and I will post the script in a minute, but I need to know how to make it so where a person, joins a teams/switches and it will show the rank of that group, for example - Jim is in the main group and the Security Department, he goes on the Security Department and it shows his rank for the Security Department.

So I can’t figure that out so any help is appreciated. (Note: Do not point out any grammar mistakes, it’s annoying getting notified and check and it’s just someone saying “Misspelled that.” and if you don’t understand then I will reply and try to explain the best I can… Here is the script)

game.Players.PlayerAdded:Connect(onPlayerRespawned)

function onPlayerRespawned(newPlayer)
	
	wait(0.01)
	
	local gui = script.Rank:clone()
	
	gui.Parent=newPlayer.Character.Head
	gui.Adornee=newPlayer.Character.Head
	
	local texta=gui.Frame.PlayerRank
	texta.Text = (newPlayer:GetRoleInGroup(7954411))
	
	local textb=gui.Frame.PlayerName
	textb.Text = newPlayer.Name
	
	wait(.001)
	
	-- Departments
	
		if newPlayer.TeamColor == game.Teams["Manufacturing Department"].TeamColor then
		
			texta.Text = (newPlayer:GetRoleInGroup(N/A))
			
		--		texta.TextColor3 = Color3.new(255, 176, 0)
		
		elseif newPlayer.TeamColor == game.Teams["Department of External Affairs"].TeamColor then
		
			texta.Text = (newPlayer:GetRoleInGroup(7954714))
			
		--		texta.TextColor3 = Color3.new(255, 176, 0)
		
		elseif newPlayer.TeamColor == game.Teams["Ethics Committee"].TeamColor then
		
			texta.Text = (newPlayer:GetRoleInGroup(N/A))
			
		--		texta.TextColor3 = Color3.new(39, 70, 45)
		
		elseif newPlayer.TeamColor == game.Teams["Internal Security Department"].TeamColor then
		
			texta.Text = (newPlayer:GetRoleInGroup(7955170))
			
		--		texta.TextColor3 = Color3.new(163, 75, 75)
	
		elseif newPlayer.TeamColor == game.Teams["Medical Department"].TeamColor then
		
			texta.Text = (newPlayer:GetRoleInGroup(N/A))
			
		--		texta.TextColor3 = Color3.new(4, 175, 236)
	
		elseif newPlayer.TeamColor == game.Teams["Mobile Task Force"].TeamColor then
		
			texta.Text = (newPlayer:GetRoleInGroup(N/A))
			
		--		texta.TextColor3 = Color3.new(0, 32, 96)
		
		elseif newPlayer.TeamColor == game.Teams["Rapid Response Team"].TeamColor then
		
			texta.Text = (newPlayer:GetRoleInGroup(7955226))
			
		--		texta.TextColor3 = Color3.new(117, 0, 0)

		
		elseif newPlayer.TeamColor == game.Teams["Intelligence Agency"].TeamColor then
	
			texta.Text = (newPlayer:GetRoleInGroup(7955063))
		
			
		--		texta.TextColor3 = Color3.new(151, 0, 0)
		
		elseif newPlayer.TeamColor == game.Teams["Scientific Department"].TeamColor then
		
			texta.Text = (newPlayer:GetRoleInGroup(N/A))
			
		--		texta.TextColor3 = Color3.new(13, 105, 172)
		
		elseif newPlayer.TeamColor == game.Teams["Security Department"].TeamColor then
		
			texta.Text = (newPlayer:GetRoleInGroup(N/A))
		
		--		texta.TextColor3 = Color3.new(91, 93, 105)
		
		elseif newPlayer.TeamColor == game.Teams["Foundation Personnel"].TeamColor then
		
			texta.Text = (newPlayer:GetRoleInGroup(7954411))
			
		--		texta.TextColor3 = Color3.new(202, 203, 209)
		
		elseif newPlayer.TeamColor == game.Teams["Class-D"].TeamColor then
		
			texta.Text = "Class-D"
	
			--texta.TextColor3 = Color3.new(255, 85, 0)
	
		end
	
	-- Customs [SiD+]
	while wait(1) do
		if newPlayer.Name == "N/A" then
			
		--SiD
		
			textb.Text = "N/A"
		
		elseif newPlayer.Name == "[The Administrator]" then
			
		--MTF
		
			textb.Text = "O5-1"
			texta.Text = "[CLASSIFIED]"
		
		elseif newPlayer.Name == "" then
			
		--ScD
		
			textb.Text = "O5-2"
			texta.Text = "[CLASSIFIED]"
			
		elseif newPlayer.Name == "" then
			
		--SD
		
			textb.Text = "O5-3"
			texta.Text = "[CLASSIFIED]"
			
		elseif newPlayer.Name == "" then
			
		--MD
		
			textb.Text = "O5-4"
			texta.Text = "[CLASSIFIED]"
			
		elseif newPlayer.Name == "" then
		
		--EC
		
			textb.Text = "O5-5"
			texta.Text = "[CLASSIFIED]"
			
		elseif newPlayer.Name == "" then
		
		--E&T
		
			textb.Text = "O5-6"
			texta.Text = "[CLASSIFIED]"
			
		elseif newPlayer.Name == "" then
		
		--IA
		
			textb.Text = "O5-7"
			texta.Text = "[CLASSIFIED]"
			
		elseif newPlayer.Name == "" then
		
		--ISD
		
			textb.Text = "O5-8"
			texta.Text = "[CLASSIFIED]"
			
		elseif newPlayer.Name == "" then
		
		--PO
		
			textb.Text = "O5-9"
			texta.Text = "[CLASSIFIED]"
			
		elseif newPlayer.Name == "" then
		
		--MaD
		
			textb.Text = "O5-10"
			texta.Text = "[CLASSIFIED]"
			
		elseif newPlayer.Name == "pupik22822" then
		
		--O5-X
		
			textb.Text = "Pupik22822"
			texta.Text = "O5-Head"
			
		elseif newPlayer.Name == "WizardlyChap4514" then
		
		--The Administrator
		
			textb.Text = "WizardlyChap4514"
			texta.Text = "[The Administrator]"
			
		elseif newPlayer.Name == "WizardlyChap4514" then

			--N/A

			textb.Text = "N/A"
			texta.Text = "Blank"
			
		
		end
		
	end
	
end





function onPlayerEntered(newPlayer)
	newPlayer.Changed:connect(function (property)
		if (property == "Character") then
			onPlayerRespawned(newPlayer)
		end
	end)
end

game.Players.PlayerAdded:connect(onPlayerEntered)

(Note: This is not my script, but it doesn’t work so need some help)
The Error is when a person joins a team it will just show the main group rank.

2 Likes

What about it doesn’t work? Does it error?

1 Like

When you switch teams it just shows the main group rank.

elseif newPlayer.Name == "WizardlyChap4514" then
		
		--The Administrator
		
			textb.Text = "WizardlyChap4514"
			texta.Text = "[The Administrator]"

Could it be due to this section overriding your own nametag? Do other accounts also have the same bug?

Yes, One of the DEA Members switched teams and it didn’t work.

This is kinda extra and not needed

game.Players.PlayerAdded:Connect(function(player)
   player.CharacterAdded:Connect(function(character)
      onPlayerRespawn(player)
   end
end)

wait(0.01) defaults to 0.03 btw so wait() will do just as well
(same thing with wait(0.001))

Also there is no guarantee that the Head is in the game yet, this is where you would probably use :WaitForChild("child name here")


Anyways lets go back to the original problem. I’m not entirely sure the purpose of you using a loop for the custom tags. You should be fine to call it once unless player names are changing. Try removing the loop. It should function correctly from what I can see

Ok thanks I will test it and see if it works, Thanks.

Sorry got confused @kingerman88, so I can delete this?

And what do I do with this?

Those act the exact same
The bottom one is a replacement for the top one except is more efficient

Yeah, it didn’t work it just stopped working…

What is the main group rank? /

The main group rank is like, SCPF the main group is the one with Level-1 Etc and the divisions like Mobile Task Force and Security.

From what I can see you have a main group and you have other groups as well. When someone switches, it should change the nametag right?

local rank = newPlayer:GetRoleInGroup(7954411)
elseif rank == ""Department of External Affairs"" then 
 -- change colour here

Yeah, it should but it doesn’t.

Are you doing this in a script or local script? You should be doing it in a local script.

I dunno. Doesn’t seem like anything’s wrong.

There are many OverheadGui/Nametag scripts out there. Like this one: OverheadGui

Yes, but it only works for 1 group.