Health bar copy in scriptblox website only to work
Key RequiredUniversal

Health bar copy in scriptblox website only to work

Universal ScriptNULL01NULL01 1.2K views 74 executesUpdated Jul 23, 2025
Unrated
00
Lua Script•73 lines (2398 chars)
local Players = game:GetService("Players")

local function createHealthBar(player)
    local character = player.Character
    if not character then return end

    local humanoid = character:FindFirstChild("Humanoid")
    local head = character:FindFirstChild("Head")
    if not humanoid or not head then return end

    -- Remove old health bar if exists
    local oldGui = head:FindFirstChild("HealthBarGui")
    if oldGui then oldGui:Destroy() end

    local billboardGui = Instance.new("BillboardGui")
    billboardGui.Name = "HealthBarGui"
    billboardGui.Adornee = head
    billboardGui.Size = UDim2.new(4, 0, 1, 0)
    billboardGui.StudsOffset = Vector3.new(0, 2.5, 0)
    billboardGui.AlwaysOnTop = true
    billboardGui.Parent = head

    local background = Instance.new("Frame")
    background.Size = UDim2.new(1, 0, 0.3, 0)
    background.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
    background.BorderSizePixel = 1
    background.Parent = billboardGui

    local healthBar = Instance.new("Frame")
    healthBar.Size = UDim2.new(1, 0, 1, 0)
    healthBar.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
    healthBar.BorderSizePixel = 0
    healthBar.Parent = background

    local healthText = Instance.new("TextLabel")
    healthText.Size = UDim2.new(1, 0, 1, 0)
    healthText.BackgroundTransparency = 1
    healthText.TextColor3 = Color3.fromRGB(255, 255, 255)
    healthText.TextStrokeTransparency = 0.7
    healthText.Font = Enum.Font.SourceSansBold
    healthText.TextSize = 14
    healthText.Parent = background

    local function updateHealth()
        local health = humanoid.Health
        local maxHealth = humanoid.MaxHealth
        local healthPercent = math.clamp(health / maxHealth, 0, 1)

        healthBar.Size = UDim2.new(healthPercent, 0, 1, 0)
        healthText.Text = string.format("%d / %d", math.floor(health), math.floor(maxHealth))
    end

    humanoid.HealthChanged:Connect(updateHealth)
    updateHealth()
end

local function onCharacterAdded(character)
    local player = Players:GetPlayerFromCharacter(character)
    if player then
        createHealthBar(player)
    end
end

for _, player in pairs(Players:GetPlayers()) do
    if player.Character then
        createHealthBar(player)
    end
    player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(onCharacterAdded)
end)

Features & Information

Yeah idk what it's useful for.
#healthbar

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts