0 views0 copies0 likes
Health Bar for New and Returning Characters
Universal script
Copy it, then test it in your own Studio place.
Script code
22 lines ยท 1.1 KBlocal player = game:GetService("Players").LocalPlayerlocal gui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))gui.ResetOnSpawn = falselocal track = Instance.new("Frame", gui)track.Position, track.Size = UDim2.fromOffset(22, 105), UDim2.fromOffset(200, 17)track.BackgroundColor3 = Color3.fromRGB(35, 38, 51)local bar = Instance.new("Frame", track)local healthConnection, maxConnectionlocal function bind(character) if healthConnection then healthConnection:Disconnect(); maxConnection:Disconnect() end local characterHumanoid = character:WaitForChild("Humanoid") local function refresh() local ratio = math.clamp(characterHumanoid.Health / math.max(1, characterHumanoid.MaxHealth), 0, 1) bar.Size = UDim2.fromScale(ratio, 1)-- โฆopen Get script for the full sourceAbout this script
Put this LocalScript into StarterPlayerScripts to show a compact health bar outside combat menus. It rebinds to the new Humanoid when the character resets, updates when Health or MaxHealth changes, and shifts from red to green as health rises. Test with a hazard and a healing station, then customize its position to avoid overlapping your other HUD elements.
Log in to leave a comment.
No comments yet
Be the first to share your thoughts!
Comments
Share what works, ask questions, or report an issue.