Загрузка данных


local player = game.Players.LocalPlayer

local HitPoints = script.Parent.Front

local container = HitPoints.Parent

local function onHealthChanged()

        local human = player.Character.Humanoid

        local percent = human.Health / human.MaxHealth

        HitPoints.Size = UDim2.new(percent, 0, 1, 0)

        if percent < .1 then

                HitPoints.BackgroundColor3 = Color3.new(1, 0, 0)

        elseif percent < .4 then

                HitPoints.BackgroundColor3 = Color3.new(1, 1, 0)

        else

                HitPoints.BackgroundColor3 = Color3.new(0, 1, 0)

        end

end

local function onCharacterAdded(character)

        local human = character:WaitForChild("Humanoid")

        human.HealthChanged:Connect(onHealthChanged)

        onHealthChanged()

end

player.CharacterAdded:Connect(onCharacterAdded)

if player.Character then

        onCharacterAdded(player.Character)

end