How do I hide enemy names?

The problem is that I don’t know how to hide the names of enemy players in my game or where I should look to find out how to. I already checked youtube, but it was all enemy occlusion, which only hid names behind walls.

1 Like

In a local script, you can iterate over all players in the server in and check if they are an enemy to the local player, and if they are, set the player.Character.Humanoid.DisplayDistanceType to Enum.HumanoidDisplayDistanceType.None

2 Likes

Just as @JamiePro248clone said above, this is what the script could look like:

local redTeam = game:GetService("Teams"):FindFirstChild("Red")
local blueTeam = game:GetService("Teams"):FindFirstChild("Lapis")

if game.Players.LocalPlayer.TeamColor == BrickColor.new("Lapis") then --check if you are on the blue team
	for i, enemy in pairs(redTeam:GetPlayers()) do --go through all enemies and disable names
		enemy.NameDisplayDistance = 0
	end
else --if theyre not in the blue team, disable their names
	for i, enemy in pairs(blueTeam:GetPlayers()) do --go through all enemies and disable names
		enemy.NameDisplayDistance = 0
	end
end

this should work, lmk if theres any issues but obvs you would need to hook it up to a trigger, for example when a match starts a remoteevent is fired to all clients.

2 Likes

I swapped out lapis and red for my own team names and got it to work for Peacekeepers. If I can get it to work for Resistance, it will be perfect.

local redTeam = game:GetService("Teams"):FindFirstChild("Resistance")
local blueTeam = game:GetService("Teams"):FindFirstChild("PeaceKeepers")

if game.Players.LocalPlayer.TeamColor == BrickColor.new("PeaceKeepers") then --check if you are on the blue team
	for i, enemy in pairs(redTeam:GetPlayers()) do --go through all enemies and disable names
		enemy.NameDisplayDistance = 0
	end
else --if theyre not in the blue team, disable their names
	for i, enemy in pairs(blueTeam:GetPlayers()) do --go through all enemies and disable names
		enemy.NameDisplayDistance = 0
	end
end

I tried to make a copy of this and swap the teams around so the script attempts to hide Peacekeepers and it ended up hiding both teammate and enemy names.

1 Like

Well I mean yeah, the code is hiding both team display names.

I think you should just check what team the player is on, and then hide the opposite team.

And do this from the server through fireallclients for example, this current code is easily exploitable in my opinion because exploiters can read and rewrite local scripts. This is why it would be better to do this from the server through fireallclients.

Or just do this on the client and use a server-check with remote events to verify the information.