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.
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)
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).
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