Easy Billboard Gui on Teammates

Hi all,

I am currently working on a very unique Street Soccer game and I’m trying to make it as user-friendly as possible for everyone to enjoy. I’m trying to make a billboard gui that gets cloned on top of everyone’s character in my team since people with Rthro packages might not have their in-game team uniforms on in order to avoid any possible confusion and promote team work.


image

This is a localscript, put inside a GUI that resets on spawn (so the script resets on spawn).

--< Services
local PlayerService = game:GetService('Players')

--< Variables
local Player = PlayerService.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()

local Team = Player.Team


for i, plr in ipairs(game.Players:GetPlayers()) do
	if plr.Character then
		if plr:FindFirstChild("TeamMarker") then
			plr.TeamMarker:Destroy()
		end
	end
end

for i, teamate in ipairs(Team:GetPlayers()) do
	if teamate.Character and teamate.Name~= Player.Name then
		local marker = script.TeamMarker:Clone()
		marker.Parent = teamate.Character
		marker.Enabled = true
	end
end


game.Workspace.ChildAdded:Connect(function(char)
	if game.Players:GetPlayerFromCharacter(char) then
		local p  = game.Players:GetPlayerFromCharacter(char)
		if p.TeamColor == Team.TeamColor and p.Name ~= Player.Name then
			local marker = script.TeamMarker:Clone()
			marker.Parent = char
			marker.Enabled = true
		end
	end
end)

The issue I’m encoutering with this is that the script only works halfway. When I join the game, all my teamates are marked fine. However, when a player respawns or a new player joins, they are not marked as my teamate despite being in my team so the issue should be inside the ChildAdded event.

image

No error has been printed in the output. If anybody can help me locate the error I’d greatly appreciate it. :heart:

Thanks in advance!

1 Like

Hey R_obots!

I’m not sure if gui resetonspawn resets the local script inside of it as well, I could be mistaken but if I am correct then put your for loops in a function and call it every time your workspace.ChildAdded connection activates. (Other solutions could be detecting a character join on the server, then fireAllClients to add a team Ui IF one does not already exist in said player)

Side note: In this case it is probably better to use a character joined function (similar to a player joined function) rather than just checking for anything added to the workspace.

1 Like

Thanks! I’ve added a remote event that :FireAllClients() everytime a character gets added to workspace. It works.