Usernames only among teams

How do you make it so that only teammates can see usernames or display names? I’ve looked in a lot of places, but those just talk about custom nametags. But, I am using Roblox’s default nametags.

Sadly, I think a custom name tag is the only way to go about it.

Go trough all the teams and set the other teams humanoids DisplayDistanceType to “None”


for i,v in ipairs(game.Teams:GetChildren()) do
	if v ~= YourTeam then
		for pos,plr in ipairs(v:GetPlayers()) do
			plr.Character.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
		end
	end
end

Where do I put this? (30 aaaaaaaaa)

(lol wrong post sorry)

Put it inside a local script inside PlayerGui

local Player = game.Players.LocalPlayer

for i,v in ipairs(game.Teams:GetChildren()) do
	if v ~= Player.Team then
		for pos,plr in ipairs(v:GetPlayers()) do
			plr.Character.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
		end
	end
end

Here’s the updated version

I don’t have a script. (30 aaaa)

It doesn’t work, the other team can still see the other team’s nametags.

Probably because the team changes after it has set the nametags. I can’t help you there though because you will have to add it to your own scripts which handle the team changes.

Oh, thank you! I just had to make it wait for one second.