local function updatePlayers()
players = game.Players:GetPlayers()
local pos = 0
for _, search in pairs(script.Parent.UI.TeamBars:GetChildren()) do
if string.match(search.Name, "Player_") then
search:Destroy()
end
end
for index, player in pairs(players) do
if player.Name ~= MainPlayer.Name and player.Character and MainPlayer.TeamColor ~= "Really blue" then
if player.TeamColor == MainPlayer.TeamColor then
local positionFactor = .15 * pos
pos = pos + 1
local PlayerHUD = TeamMemberDisplay:Clone()
PlayerHUD.Name = "Player_"..player.Name.."_Health"
PlayerHUD.Parent = script.Parent.UI.TeamBars
PlayerHUD.PlayerName.Text = player.Name
PlayerHUD.Position = UDim2.new(0.05 + positionFactor, 0, 0.865, 0)
local function setHealthForPlayer()
if player.Character then
humanoid = player.Character:WaitForChild("Humanoid")
if humanoid then
local HealthyColor = endColor:lerp(startColor, player.Character.Humanoid.Health/100)
if PlayerHUD:FindFirstChild("HealthBacking") then
if player.Character.Humanoid.Health == 0 then PlayerHUD.HealthBacking.PlayerStatus.Visible = true end
PlayerHUD.HealthBacking.HealthBar.BackgroundColor3 = Color3.new(HealthyColor.x/255, HealthyColor.y/255, HealthyColor.z/255)
PlayerHUD.HealthBacking.HealthAmount.TextStrokeColor3 = Color3.new(HealthyColor.x/255, HealthyColor.y/255, HealthyColor.z/255)
PlayerHUD.HealthBacking.HealthBar.Size = UDim2.new(player.Character.Humanoid.Health/100,0,1,0)
PlayerHUD.HealthBacking.HealthAmount.Text = "+"..tostring(math.floor(player.Character.Humanoid.Health))
end
end
end
player.Character.Humanoid.Changed:connect(setHealthForPlayer)
end
setHealthForPlayer()
end
end
end
end
Without warning. I'm not sure why.
-=Robo=- |