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.
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.
No error has been printed in the output. If anybody can help me locate the error I’d greatly appreciate it.
Thanks in advance!