Overhead gui help

How to make an overhead gui to everyone, but there is a special team called Redacted
So this Redacted team, when other people (non redacted) see Redacted’s player overhead, they see text “Redacted”, but if people is in Redacted too, they see others Redacted overhead as others username.
I give an example of 5 players (Player A, B, C, D and E)
Player A and D is Redacted
B, C, and E is not on Redacted Team.
I want it when player A see player D overhead they see it as Player D’s username, but when player B, C, and E see player D overhead, they see it as “Classified”.

Is it possible? if yes, how to make it? Please help me. Thank you.

I guess in a local script in StarterGui, try this:

if game.Players.LocalPlayer.Team ~= game.Teams.Redacted then
	for i, v in pairs(game.Players:GetPlayers()) do
		if v.Team == game.Teams.Redacted then
			v.Character.Head["OverheadGui"].TextLabel.Text = "Redacted"
		else
			v.Character.Head["OverheadGui"].TextLabel.Text = ""
		end
	end
end

Obviously adjust the code so that the Overhead UI and text are located

2 Likes

But Can i still make the overhead by server script and add with this local script or need to change into the overhead to local script too

I’m not sure I overly understand what you’re saying. Try placing the above code in a local script in StarterGui, and make sure the Overhead UI is in StarterCharacterScripts and parent it to the Head or something

But is the same is make the gui with server script and clone it to head right?

Yes, place a regular script in StarterCharacterScripts parenting the UI to the head

Oh and also i want it that Player who’s on Team Redacted too, see other Redacted with the player username(The other), but when outside team see Redacted they see it as “Classified” how to do it?

Is this what you wanted?

local Player = game.Players.LocalPlayer
local Teams = game:GetService("Teams")

for i, v in pairs(game.Players:GetPlayers()) do
	if v.Team == Teams.Redacted then
		v.Character.Head["OverheadGui"].TextLabel.Text = "Redacted"
	else
		if Player.Team == Teams.Redacted then
			v.Character.Head["OverheadGui"].TextLabel.Text = v.Name
		else
			v.Character.Head["OverheadGui"].TextLabel.Text = "Classified"
		end
	end
end
if game.Players.LocalPlayer.Team ~= game.Teams.Redacted then
	for i, v in pairs(game.Players:GetPlayers()) do
		if v.Team == game.Teams.Redacted then
			v.Character.Head["OverheadGui"].TextLabel.Text = v.Name
		else
			v.Character.Head["OverheadGui"].TextLabel.Text = "Redacted"
		end
	end
end

Can I make like this? I think this is work, so player on Redacted see other Redacted as v.Name but player outside Redacted see Redacted overhead as “Redacted”

If that’s how you want it, and you can mark this as solved if it works for you

Alright I will but can you explain about your second code?

local Player = game.Players.LocalPlayer
local Teams = game:GetService("Teams")

for i, v in pairs(game.Players:GetPlayers()) do
	if v.Team == Teams.Redacted then
		v.Character.Head["OverheadGui"].TextLabel.Text = "Redacted"
	else
		if Player.Team == Teams.Redacted then
			v.Character.Head["OverheadGui"].TextLabel.Text = v.Name
		else
			v.Character.Head["OverheadGui"].TextLabel.Text = "Classified"
		end
	end
end

Oh yes, I already make it as a solution, your first code. But only to learn what’s the meaning for the second code.

It basically goes through all players and gives the local player a different view of the titles depending on their team

If you don’t understand the code, for i, v in pairs(game.Players:GetPlayers()) do loops through all the Players, and the code in between checks the team of each player.

-- Server Script --
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local gui = script.Over:Clone()
		local name = gui.pName
		name.Text = player.Name
		gui.Parent = char.Head
	end)
end)

-- Local Script -- 
if game.Players.LocalPlayer.Team ~= game.Teams.Redacted then
	for i, v in pairs(game.Players:GetPlayers()) do
		if v.Team == game.Teams.Team2 then
			v.Character:WaitForChild("Head").Over.pName.Text = v.Name
		else
			v.Character:WaitForChild("Head").Over.pName.Text = "Redacted"
		end
	end
end

If I make like this, does it mean if player outside team 2 they check if other player see team Redacted they see it as Redacted but if they are on team 2, they see it as other player username

Can i just remove it into,

if game.Players.LocalPlayer.Team ~= game.Teams.Redacted then
	for i, v in pairs(game.Players:GetPlayers()) do
		if v.Team == game.Teams.Team2 then
			v.Character:WaitForChild("Head").Over.pName.Text = "Redacted"
		end
	end
end

Because I already make player Name for the text on the server script. Can I?

Oh and also can I make my overhead not visible for myself? I mean sometimes it’s annoying to see our own overhead

Yes that will probably work if that’s what you are after

Okay, thank you. For the last thing, how to make our own overhead is not visible for us. I don’t want to see my own overhead, same like other players don’t want to see their own overhead.

Short code but solved my problems, thank you so much.

Attempted to index nil with Head on the local script