How to show teammate names through walls at infinite distances

im trying to make it so it will show only teammate names through walls forever but i only got teammate names to show through walls but everyone’s names to show forever i changed the nameocclusion to enemy occlusion and make the health/name display distance to a big number i dont know what else to try

2 Likes

Assuming that team A and team B exist:
There is a team A player. For which team teammate name should be visible through walls at infinite distances and not visible through walls at infinite distances?
a) team A
b) team B

all team A players should be able to see all team A names through walls at infinite distances but not see any team B names through walls and not at infinite distances (so team A should see team B names normally) same thing for the other team

From my experience of testing the occlusion system I came to a conclusion that name occlusion is weird. Basically it works like almost nobody or nobody would think that it works like that. Here are two screenshots of my testing (server POV and client POV):



Someone here explained how it actually works. My way around it to make a local scripts, which puts BillboardGuis with AlwaysOnTop = true above teammates heads. The GUI itself can be a dot with team color.

i know how it works but i want it to show the original or copy of the name tag not a dot i know billboardguis would work but i dont have the original name tag gui that is shown above the player

i want it to be like this
image
that picture is a name from across the map but that only happens with teammates and not any other players

if i set the display distance to a huge number that will set it for everyone not just teammates making people be able to see enemies names across the map which i do not want

more pictures
image

I couldn’t find humanoid default nametag GUI in Explorer (yes, I enabled “Show Hidden Objects in Explorer” in Studio settings). Making custom nametag system (or recreation of the default one) is only what I came up with.

In starter character scripts do: (Sever script)

script.Parent:WaitForChild("Humanoid").NameOcclusion = Enum.NameOcclusion.EnemyOcclusion
script.Parent.Humanoid.NameDisplayDistance = math.huge

BillboardGui.TextLabel.Text = Player.DisplayName

This would set the text in a billboard gui to the display name of a player

i do not want this to happen

that would make it show everyone’s names through walls i just want teammates

Did you set the name occlusion mode?

I would suggest making people’s names with BillboardGui’s because roblox character names aren’t really that customizable.

I would on every frame loop through everybody and if they are on the same team show their names, if they are on the opposite team then raycast to see if the player can currently see them… If they can then show the billboard gui

yes i set it to the enemyocclusion

Oh, in that case locally set the other teams player name display distance to 0.

1 Like

script if wanted:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:WaitForChild("Humanoid").NameOcclusion = Enum.NameOcclusion.EnemyOcclusion
		char.Humanoid.NameDisplayDistance = math.huge
		
		while wait() do
			for i,v in pairs(game.Players:GetChildren()) do
				if v.TeamColor ~= plr.TeamColor then
					v.Character.Humanoid.NameDisplayDistance = 100
				end
			end
		end
	end)
end)

Do you mean:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:WaitForChild("Humanoid").NameOcclusion = Enum.NameOcclusion.EnemyOcclusion
		char.Humanoid.NameDisplayDistance = math.huge
		
		while wait() do
			for i,v in pairs(game.Players:GetChildren()) do
				if v.TeamColor ~= plr.TeamColor then
					v.Character.Humanoid.NameDisplayDistance = 0
				end
			end
		end
	end)
end)

no i wanted it still to show at close ranges and also i changed it

client:

script.Parent:WaitForChild("Humanoid").NameOcclusion = Enum.NameOcclusion.EnemyOcclusion
script.Parent.Humanoid.NameDisplayDistance = math.huge
script.Parent.Humanoid.HealthDisplayDistance = math.huge

local function getPlayerFromCharacter(character)
	for _, player in pairs(game:GetService("Players"):GetPlayers()) do
		if player.Character == character then
			return player
		end
	end
end

while wait() do
	game.ReplicatedStorage.TeamEvents.CheckName:FireServer(getPlayerFromCharacter(script.Parent))
end

server:

game.ReplicatedStorage.TeamEvents.CheckName.OnServerEvent:Connect(function(plr)
	for i,v in pairs(game.Players:GetChildren()) do
		if v.TeamColor ~= plr.TeamColor then
			v.Character.Humanoid.NameDisplayDistance = 100
			v.Character.Humanoid.HealthDisplayDistance = 100
		end
	end
end)

There is a built in function in game.Players called :GetPlayerFromCharacter(), use that instead.