The nametag itself works perfectly fine, but when a player tries to go into a different team since they joined that group (the team is linked to the group, and shows the rank they are in), the nametag doesn’t change at all.
Nametag would change color based on what team they are in, but doesn’t do that at all.
If anyone could help, that would be awesome.
local groupID = 32989980
local HQ = 33923356
local ESFOZA = 33923463
local RG = 33534442
local TERDAC = 33923286
local ZAAF = 33923232
local ZAMPC = 33923505
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local ranks = {
[255] = {Name = "[Z] Director", Image = "rbxassetid://16514021179", Color = Color3.fromRGB(255, 167, 43)},
[254] = {Name = "[HDEV] Head Developer", Image = "rbxassetid://16514021179", Color = Color3.fromRGB(255, 167, 43)},
[253] = {Name = "[DEV] Developer", Image = "rbxassetid://16514021179", Color = Color3.fromRGB(255, 167, 43)},
[252] = {Name = "[CZA] Chairman of ZA", Image = "rbxassetid://16514021179", Color = Color3.fromRGB(255, 167, 43)},
[251] = {Name = "[AA] Arch Admiral", Image = "rbxassetid://16514021179", Color = Color3.fromRGB(255, 167, 43)},
[250] = {Name = "[A] Admiral", Image = "rbxassetid://16514021179", Color = Color3.fromRGB(255, 167, 43)},
[24] = {Name = "[CO] Commander", Image = "rbxassetid://16514021179", Color = Color3.fromRGB(255, 167, 43)},
[22] = {Name = "[Z10] General", Image = "rbxassetid://16514021179", Color = Color3.fromRGB(255, 167, 43)},
[21] = {Name = "[Z9] Lieutenant General", Image = "rbxassetid://16514021179", Color = Color3.fromRGB(255, 167, 43)},
[20] = {Name = "[Z8] Major General", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(255, 167, 43)},
[19] = {Name = "[Z7] Brigadier General", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(255, 167, 43)},
[18] = {Name = "[Z6] Colonel", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(255, 167, 43)},
[17] = {Name = "[Z5] Lieutenant Colonel", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(255, 167, 43)},
[16] = {Name = "[Z4] Major", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(255, 167, 43)},
[15] = {Name = "[Z3] Captain", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(255, 167, 43)},
[14] = {Name = "[Z2] First Lieutenant", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(255, 167, 43)},
[13] = {Name = "[Z1] Second Lieutenant", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(255, 167, 43)},
[11] = {Name = "[R11] Command Sergeant Major", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(24, 255, 217)},
[10] = {Name = "[R10] Sergeant Major", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(49, 255, 248)},
[9] = {Name = "[R9] First Sergeant", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(49, 255, 248)},
[8] = {Name = "[R8] Master Sergeant", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(49, 255, 248)},
[7] = {Name = "[R7] Sergeant First Class", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(49, 255, 248)},
[6] = {Name = "[R6] Staff Sergeant", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(49, 255, 248)},
[5] = {Name = "[R5] Sergeant", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(49, 255, 248)},
[4] = {Name = "[R4] Corporal", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(125, 125, 125)},
[3] = {Name = "[R3] Specialist", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(125, 125, 125)},
[2] = {Name = "[R2] Private First Class", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(125, 125, 125)},
[1] = {Name = "[R1] Private [Combat Training]", Image = "rbxassetid://17365601663", Color = Color3.fromRGB(125, 125, 125)}
}
local divisions = {
[ESFOZA] = {Prefix = "[ESFOZA]", Image = "rbxassetid://16514196686", Color = Color3.fromRGB(190, 180, 172)},
[TERDAC] = {Prefix = "[TERDAC]", Image = "rbxassetid://16513878352", Color = Color3.fromRGB(255, 48, 6)},
[RG] = {Prefix = "[RG]", Image = "rbxassetid://16433575026", Color = Color3.fromRGB(255, 162, 0)},
[ZAMPC] = {Prefix = "[ZAMPC]", Image = "rbxassetid://16514272731", Color = Color3.fromRGB(255, 98, 25)},
[ZAAF] = {Prefix = "[ZAAF]", Image = "rbxassetid://16513766481", Color = Color3.fromRGB(58, 252, 255)},
[HQ] = {Prefix = "[HQ]", Image = "rbxassetid://16514021179", Color = Color3.fromRGB(255, 167, 26)}
}
local function SetupOverheadUI(player, character)
local head = character:WaitForChild("HumanoidRootPart")
local overheadUI = script.OverheadGUI:Clone()
overheadUI.Parent = head
overheadUI.PlrName.Text = player.Name
overheadUI.PlrRank.Text = player:GetRoleInGroup(groupID)
local rank = ranks[player:GetRankInGroup(groupID)]
local division = overheadUI.Divisions
if rank then
division.DivName.Text = rank.Name
division.DivImage.Image = rank.Image
division.DivDesign.BackgroundColor3 = rank.Color
else
local inGroup = false
for group, info in pairs(divisions) do
if player:IsInGroup(group) then
division.DivName.Text = info.Prefix .. " " .. player:GetRoleInGroup(group)
division.DivImage.Image = info.Image
division.DivDesign.BackgroundColor3 = info.Color
inGroup = true
break
end
end
if not inGroup then
if player:IsInGroup(groupID) then
division.DivName.Text = "Divisionless"
division.DivImage.Image = "rbxassetid://17365601663"
division.DivDesign.BackgroundColor3 = Color3.fromRGB(152, 166, 177)
else
division.DivName.Text = "Civilian"
division.DivImage.Image = "rbxassetid://17365601663"
division.DivDesign.BackgroundColor3 = Color3.fromRGB(170, 0, 255)
end
end
end
if UIS.TouchEnabled and not UIS.KeyboardEnabled then
overheadUI.Icons.Mobile.Visible = true
elseif UIS.KeyboardEnabled and not UIS.TouchEnabled then
overheadUI.Icons.PC.Visible = true
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
SetupOverheadUI(player, character)
end)
end)