Team only overhead gui

hi so i made a script to assign different overhead gui for different teams but the thing is that i wanna make it that red team can only see their teammate overhead gui and cant see their opponent team overhead gui and this goes same with blue team.How would i achieve this?

local groups = {
	main = 000000
}


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		char.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
		local clone = script.Nametag:Clone()
		clone.Parent = char.Head
		clone.Namey.Text = player.Name
		clone.Rank.Text = player:GetRoleInGroup(groups.main)
		if player.TeamColor == BrickColor.new("Really red") then
			clone.Namey.TextColor3 = Color3.fromRGB(255, 0, 4)
			clone.Rank.TextColor3 = Color3.fromRGB(255, 0, 4)
		elseif player.TeamColor == BrickColor.new("Electric blue") then
			clone.Namey.TextColor3 = Color3.fromRGB(9, 137, 207)
			clone.Rank.TextColor3 = Color3.fromRGB(9, 137, 207)
		end
	end)
end)

this is my current overhead gui script
Thx for any help.Good day

1 Like

Please send an image of the explorer so I can replicate the explorer to make an example that I think will work

1 Like

So you want it like in arsenal, or phantom forces?

1 Like

yes like in arsenal where i be able to see only my teammate names but not my opponent and here is the explorer
image

1 Like

Is the script in ServerScriptService? Also sorry for not replying I have been doing chores. Just tell me what the scripts parent is.

1 Like

yes it is in serverscript service

2 Likes

Can I make a model? I want to make a model, so it’s easier for me to understand but you can always customize how I made the billboard GUIs or whatever else you want.

1 Like

Your going to have to hide it on the client of the players that side your trying to hide.

1 Like

yes sure you can do whatever you want,i just wanna know a solution to it

1 Like

i think ill try that idea thanks

1 Like
-- LOCAL SCRIPT --
local players = game:GetService("Players")
local repStorage = game:GetService("ReplicatedStorage")
local redTeamRemote = repStorage:WaitForChild("RedTeamRemote")
local blueTeamRemote = repStorage:WaitForChild("BlueTeamRemote")

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		if player.TeamColor == BrickColor.new("Really red") then
			redTeamRemote:FireServer()
		elseif player.TeamColor == BrickColor.new("Electric blue") then
			blueTeamRemote:FireServer()
		end
	end)
end)

-- SERVER SCRIPT --
local repStorage = game:GetService("ReplicatedStorage")
local redTeamRemote = repStorage:WaitForChild("RedTeamRemote")
local blueTeamRemote = repStorage:WaitForChild("BlueTeamRemote")
local teams = game:GetService("Teams")
local teamList = teams:GetTeams()

local groups = {
	main = 000000
}

redTeamRemote.OnServerEvent:Connect(function(player)
	local character = player.Character
	local humanoid = character.Humanoid
	local head = character.Head
	local name = player.Name
	humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
	local clone = script.Nametag:Clone() --change reference to nametag
	clone.Parent = head
	clone.Namey.Text = name
	clone.Rank.Text = player:GetRoleInGroup(groups.main)
	clone.Namey.TextColor3 = Color3.fromRGB(255, 0, 4)
	clone.Rank.TextColor3 = Color3.fromRGB(255, 0, 4)
	for i, oppPlr in pairs(teamList[2]:GetPlayers()) do
		local oppChar = oppPlr.Character
		local oppHead = oppChar.oppHead
		local oppTag = oppHead.Nametag
		oppTag.Visible = false
	end
end)

blueTeamRemote.OnServerEvent:Connect(function(player)
	local character = player.Character
	local humanoid = character.Humanoid
	local head = character.Head
	local name = player.Name
	humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
	local clone = script.Nametag:Clone() --change reference to nametag
	clone.Parent = head
	clone.Namey.Text = name
	clone.Rank.Text = player:GetRoleInGroup(groups.main)
	clone.Namey.TextColor3 = Color3.fromRGB(9, 137, 207)
	clone.Rank.TextColor3 = Color3.fromRGB(9, 137, 207)
	for i, oppPlr in pairs(teamList[1]:GetPlayers()) do
		local oppChar = oppPlr.Character
		local oppHead = oppChar.oppHead
		local oppTag = oppHead.Nametag
		oppTag.Visible = false
	end
end)

You’ll need 2 RemoteEvent instances “RedTeamRemote” and “BlueTeamRemote” inside the ReplicatedStorage folder, also make sure the references to the nametag are correct, I’ve added comments to those lines (since script.Parent may no longer be valid reference to them).