How do I make a Team Indicator

Hello. I am trying to find a way to make a team icon pop up for players who are on the same team as you. In my game every player has a name tag called “ui_name” which has a indicator frame for the icon. How do I make it enabled for people on a mutual team?

Team Icon

Name tag

image

1 Like

You’ll probably need to do this on a LocalScript and what you can do is get all the current players inside the game using the GetPlayers() function, and check if your Local Player’s Team is equal to everyone else’s or not :thinking:

2 Likes

Inside a local script;

(I haven’t tested it, I wrote it in about 2 minutes)

local player = game.Players.LocalPlayer

local tag = game.ReplicatedStorage:WaitForChild('ui_name')
local runService = game:GetService('RunService')

function createTag(target)
    if target.Head:FindFirstChild('ui_name') then return end
    
    tag:Clone().Parent = target.Head
end

function isAlly(targetPlayer)
    if player.Team == targetPlayer.Team then
        return true
    end
    return false
end


runService.RenderStepped:Connect(function()
    for i,v in pairs(workspace:GetChildren())do
        if game.Players:FindFirstChild(v.Name) then
            if isAlly(game.Players[v.Name]) then
                createTag(v)
            end
        end
    end
end)
2 Likes