local Players = game:GetService("Players") local TweenService = game:GetService("TweenService") local CoreGui = game:GetService("CoreGui") local RunService = game:GetService("RunService") local function formatHealth(val) local rounded = math.round(val * 10) / 10 -- Rounds to 1 decimal place first if rounded % 1 == 0 then return string.format("%.0f", rounded) -- Absolutely no decimal for whole numbers else return string.format("%.1f", rounded) -- Exactly one decimal for others end end local function createHealthBar(character) local humanoid = character:WaitForChild("Humanoid", 5) local head = character:WaitForChild("Head", 5) if not humanoid or not head then return end if CoreGui:FindFirstChild(character.Name .. "_HealthBar") then CoreGui[character.Name .. "_HealthBar"]:Destroy() end local billboard = Instance.new("BillboardGui") billboard.Name = character.Name .. "_HealthBar" billboard.Parent = CoreGui billboard.Adornee = head billboard.Size = UDim2.new(4, 0, 6, 0) billboard.AlwaysOnTop = true billboard.ExtentsOffset = Vector3.new(2.8, 1, 0) -- Far right of head local mainFrame = Instance.new("Frame") mainFrame.Size = UDim2.new(0.06, 0, 0.6, 0) mainFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0) mainFrame.BackgroundTransparency = 0.5 mainFrame.BorderSizePixel = 0 mainFrame.AnchorPoint = Vector2.new(0.5, 0.5) mainFrame.Position = UDim2.new(0.5, 0, 0.5, 0) mainFrame.Parent = billboard local ghostBar = Instance.new("Frame") ghostBar.Size = UDim2.new(1, 0, 1, 0) ghostBar.AnchorPoint = Vector2.new(0, 1) ghostBar.Position = UDim2.new(0, 0, 1, 0) ghostBar.BackgroundColor3 = Color3.fromRGB(255, 255, 255) ghostBar.BackgroundTransparency = 0.3 ghostBar.ZIndex = 2 ghostBar.Parent = mainFrame local healthBar = Instance.new("Frame") healthBar.Size = UDim2.new(1, 0, 1, 0) healthBar.AnchorPoint = Vector2.new(0, 1) healthBar.Position = UDim2.new(0, 0, 1, 0) healthBar.BackgroundColor3 = Color3.fromRGB(0, 255, 120) healthBar.ZIndex = 3 healthBar.Parent = mainFrame local healthText = Instance.new("TextLabel") healthText.Size = UDim2.new(8, 0, 0.25, 0) healthText.Position = UDim2.new(0.5, 0, 0, -8) healthText.AnchorPoint = Vector2.new(0.5, 1) healthText.BackgroundTransparency = 1 healthText.TextColor3 = Color3.fromRGB(255, 255, 255) healthText.Font = Enum.Font.GothamBold healthText.TextScaled = true healthText.Parent = mainFrame local stroke = Instance.new("UIStroke") stroke.Thickness = 1.8 stroke.Parent = healthText local lastDamageTime = 0 local ghostTween = nil local function updateUI() local currentHP = humanoid.Health local hpPercent = math.clamp(currentHP / humanoid.MaxHealth, 0, 1) healthText.Text = formatHealth(currentHP) lastDamageTime = os.clock() if ghostTween then ghostTween:Cancel() end TweenService:Create(healthBar, TweenInfo.new(0.1), { Size = UDim2.new(1, 0, hpPercent, 0) }):Play() end local connection connection = RunService.Heartbeat:Connect(function() if not billboard or not billboard.Parent then connection:Disconnect() return end local now = os.clock() local targetPercent = math.clamp(humanoid.Health / humanoid.MaxHealth, 0, 1) if (now - lastDamageTime) >= 0.8 and ghostBar.Size.Y.Scale ~= targetPercent then ghostTween = TweenService:Create(ghostBar, TweenInfo.new(2, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), { Size = UDim2.new(1, 0, targetPercent, 0) }) ghostTween:Play() end end) humanoid.HealthChanged:Connect(updateUI) updateUI() character.AncestryChanged:Connect(function() if not character:IsDescendantOf(workspace) then connection:Disconnect() billboard:Destroy() end end) end local function setupPlayer(player) player.CharacterAdded:Connect(createHealthBar) if player.Character then task.spawn(createHealthBar, player.Character) end end Players.PlayerAdded:Connect(setupPlayer) for _, p in ipairs(Players:GetPlayers()) do setupPlayer(p) end