I am trying to add a team marker over the player's head so that the players in the game may recognize their teammates. I have two different GUI's and my goal is that a player could only see their teammates GUI. I wrote this script it seems to be working fine. But I have noticed sometimes some few players are missing the marker even if they are on the same team.
Here is the local script
local Players = game:GetService("Players")
local LocalPlayer = game:GetService("Players").LocalPlayer
local LocalPlayerTeam = LocalPlayer.Team.Name
local PinkTeambbg = game.ReplicatedStorage:WaitForChild("PinkTeamMark")
local BlueTeambbg = game.ReplicatedStorage:WaitForChild("BlueTeamMark")
local PinkTeamGui = PinkTeambbg:Clone()
local BlueTeamGui = BlueTeambbg:Clone()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEventTest = ReplicatedStorage:WaitForChild("RemoteEventTest")
local function AddMark(player) --Checks the color of team and adds the mark
if LocalPlayerTeam == "Pink" then
PinkTeamGui.Parent = game.Workspace:WaitForChild(player.Name):WaitForChild("Head")
else
BlueTeamGui.Parent = game.Workspace:WaitForChild(player.Name):WaitForChild("Head")
end
end
remoteEventTest.OnClientEvent:Connect(function()
for _, player in pairs(Players:GetPlayers()) do --Iterate through all the players
if player.Team.Name == LocalPlayerTeam then --And check if the player is in same team with local player
AddMark(player) --If in same Team Add Mark
end
end
end)
I'm firing the remoteEventTest under player.CharacterAdded.

1 comment
Are the players who don’t have the marker over their head players that have joined the game during the match (if you can)