How to make something happen to every player on one team

Basically, I have a nametag system which has a !tag command, this command allows people to change their tag which appears under their name, quite self explanatory, but I want it so people are able to remove/change a tag for the whole team, so how would I go about doing this, would I have to search for every player on a team, and I dont want it to need the full team name, as most of my team names are two words and from I’ve tested, it would just break.

If anyone could help it would be much appreciated

function whatever(teamName, tag)
    for _, player in pairs(game:GetService("Players"):GetPlayers()) do
        if player.Team.Name == teamName then
--- THING SHERE
        end)
end