OverheadGUI - Team synchronization

there?

yes, player.Character:WaitForChild blah blah blah

so I gotta do: character(instead of player?).Head:WaitForChild(“OverheadGUI”)

check reply above ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ

ServerScriptService.OverheadGUIScript:30: attempt to index nil with ‘WaitForChild’ - Server - OverheadGUIScript:30

send full screenshot ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ

with the current script you have
edit: this is taking too long, why not just use the model i sent you

because the model doesn’t have the team display. The script:

local Players = game:GetService("Players")

local rankInformation = require(script.RankInformation)

local connections = {}
local overHeadTemplate = script.OverheadGUI

Players.PlayerAdded:Connect(function(player)
	connections[player] = player.CharacterAdded:Connect(function(character)
		local newOverHead = overHeadTemplate:Clone()

		newOverHead.PlayerName.Text = player.Name
		newOverHead.PlayerTeam.Text = player.Team.Name
		
		for _, info in pairs (rankInformation) do
			local isPlayerInDivision = player:IsInGroup(info.groupId)
			
			if isPlayerInDivision then
				newOverHead.PlayerRank.TextColor3 = info.color
				newOverHead.PlayerRank.Text = "<i>".. player:GetRoleInGroup(info.groupId) .."</i>"
			end
		end

		newOverHead.Parent = character.Head
	end)
end)

for i, v in pairs(game.Teams:GetChildren()) do
	v.PlayerAdded:Connect(function(player)
		player.Character:WaitForChild("OverheadGUI").PlayerTeam.Text = player.Team.Name
	end)
end

Players.PlayerRemoving:Connect(function(player)
	if connections[player] then
		connections[player]:Disconnect()
		connections[player] = nil
	end
end)

Another alternative:

local function setupStats(player, head)
    --set up the gui here
    --"head" is the player's character's head object.
end

local function onPlayerAdded(player)
    player:GetPropertyChangedSignal("Team"):Connect(function()
        if player.Character then
            local head = player.Character:FindFirstChild("Head")
            if not head then return nil end
            local alreadyExistingStats = head:FindFirstChildOfClass("BillboardGui")
            if alreadyExistingStats then alreadyExistingStats:Destroy() end
            setupStats(player, head)
        end
    end)
end

Players.PlayerAdded:Connect(onPlayerAdded)