How would I make a teammate indicators that are only visible for teammates?

What is your issue?

For the past week I’ve been trying to make a teammate indicator, something that would appear overhead of a teammate’s head, and that indicator would be only visible to teammates.

What are the solutions you have tried?

I’ve tried to check when a character has been added, then checking if that character’s client is part of your team. However (for some reason) this doesn’t work.

I’ve also tried having the server tell all the clients when a character has been added, and the same thing as before. Even that didn’t work.

Conclusion

I’ve looked everywhere on the internet, but they all came with irrelevant results or just not my problem.

It’d be really helpful if someone told me what I did wrong with my methods, and help me improve and learn from my mistakes.

Testing with 3 clients on one computer (my computer is a dumpster fire) isn’t very helpful, because it is laggy as HECK. Testing with friends (they’re not always online) won’t work either.

Have a wonderful day.

3 Likes

May I ask how you did it? does it run only once once something happen? or does it always run.

2 Likes

The localscript I’m using goes something along the lines of this:

Player joins > Character is added > Check if that character’s player is a teammate > Clone a billboardGui and place it into that character’s head

And I’m very certain that it isn’t run twice.

2 Likes

I tried doing what you said but entirely in local. Hope this helps!

local Player = game.Players.LocalPlayer

local function CloneBillboard(GetPlayer, Character)
	if GetPlayer.TeamColor == Player.TeamColor then
		local Billboard = "BILLBOARD HERE"
		Billboard:Clone().Parent = Character.Head
	end
end

for _,IngamePlayer in pairs(game.Players:GetPlayers()) do -- Get ingame players
	if Player ~= IngamePlayer then
		if IngamePlayer.Character then
			CloneBillboard(IngamePlayer.Character)
		end
		IngamePlayer.CharacterAdded:Connect(function(Character)
			wait() -- Wait for the character's part to load
			CloneBillboard(IngamePlayer, Character)
		end)
	end
end

game.Players.PlayerAdded:Connect(function(NewPlayer) -- Get recently joined players
	NewPlayer.CharacterAdded:Connect(function(Character)
		wait() -- Wait for the character's part to load
		CloneBillboard(NewPlayer, Character)
	end)
end)
3 Likes

It probably isn’t run because depending on the place it is located (such as StarterGui), the PlayerAdded will not run as the script is added after the player is added. Try getting the player via game.Players.LocalPlayer and get the CharacterAdded from it (make sure it isn’t in StarterCharacterScripts).

1 Like

local team = game.Players.LocalPlayer.Team
team = team:GetPlayers()
for i,v in pairs(team) do
–ur stuff here , add billboard sth billboard.Adoorne = plr.Character.Head
end

Yeah, but the thing is, it’s only applying for the REST of your teammates, not the player.

1 Like

What do you mean, isn’t that what you wanted?

Nevermind. I think I have it nailed down.

1 Like

Can u mark a solution that worked?

Although this didn’t work, it gave me an insight on why my scripts didn’t work. Apparently I didn’t UPDATE it every time the client died, so thanks.