Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Team only overhead GUI works sometimes?

Asked by 5 years ago

This script (regular script located in ServerScriptService) works randomly. Sometimes it runs, sometimes it does not run. I've been struggling to find out the problem. What would be the error in this code?

local gui = game.ReplicatedStorage.BillboardGui

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        repeat wait() until char
        for i,v in pairs(game.Players:GetPlayers()) do
            if v.TeamColor == plr.TeamColor then
                local bg = gui:Clone()
                bg.Parent = v:WaitForChild("PlayerGui")
                bg.Adornee = char:WaitForChild("Head")
            end
        end
    end)
end)

Answer this question