Advertisement
qnidnqwid

HealthBar Script

Mar 19th, 2025 (edited)
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.23 KB | Gaming | 0 0
  1. local UI = {}
  2.  
  3. -- // StarterGui.Basic Health GUI \ --
  4. UI["1"] = Instance.new("ScreenGui", game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"))
  5. UI["1"]["Name"] = [[Basic Health GUI]]
  6. UI["1"]["ResetOnSpawn"] = false
  7.  
  8. -- // StarterGui.Basic Health GUI.Healthbar \ --
  9. UI["2"] = Instance.new("Frame", UI["1"])
  10. UI["2"]["Active"] = true
  11. UI["2"]["BorderSizePixel"] = 0
  12. UI["2"]["BackgroundColor3"] = Color3.fromRGB(0, 26, 0)
  13. UI["2"]["AnchorPoint"] = Vector2.new(1, 0)
  14. UI["2"]["Size"] = UDim2.new(0.1, 0, 0.02, 10)
  15. UI["2"]["Position"] = UDim2.new(1, -20, 0, -20)
  16. UI["2"]["BorderColor3"] = Color3.fromRGB(149, 105, 17)
  17. UI["2"]["Name"] = [[Healthbar]]
  18.  
  19. -- // StarterGui.Basic Health GUI.Healthbar.Healthbar \ --
  20. UI["3"] = Instance.new("Frame", UI["2"])
  21. UI["3"]["BorderSizePixel"] = 0
  22. UI["3"]["BackgroundColor3"] = Color3.fromRGB(0, 135, 0)
  23. UI["3"]["Size"] = UDim2.new(1, 0, 1, 0)
  24. UI["3"]["BorderColor3"] = Color3.fromRGB(149, 105, 17)
  25. UI["3"]["Name"] = [[Healthbar]]
  26.  
  27. -- // StarterGui.Basic Health GUI.Healthbar.Healthbar.LocalScript \ --
  28. UI["4"] = Instance.new("LocalScript", UI["3"])
  29.  
  30. -- // StarterGui.Basic Health GUI.Healthbar.percentage \ --
  31. UI["5"] = Instance.new("TextLabel", UI["2"])
  32. UI["5"]["TextWrapped"] = true
  33. UI["5"]["TextScaled"] = true
  34. UI["5"]["BackgroundColor3"] = Color3.fromRGB(255, 255, 255)
  35. UI["5"]["TextSize"] = 14
  36. UI["5"]["FontFace"] = Font.new([[rbxasset://fonts/families/SourceSansPro.json]], Enum.FontWeight.Bold, Enum.FontStyle.Normal)
  37. UI["5"]["TextColor3"] = Color3.fromRGB(255, 255, 255)
  38. UI["5"]["BackgroundTransparency"] = 1
  39. UI["5"]["AnchorPoint"] = Vector2.new(0.5, 0.5)
  40. UI["5"]["Size"] = UDim2.new(1, 0, 1, 0)
  41. UI["5"]["BorderColor3"] = Color3.fromRGB(28, 43, 54)
  42. UI["5"]["Text"] = [[100%]]
  43. UI["5"]["Name"] = [[percentage]]
  44. UI["5"]["Position"] = UDim2.new(0.5, 0, 0.5, 0)
  45.  
  46. -- // StarterGui.Basic Health GUI.Healthbar.percentage.UIStroke \ --
  47. UI["6"] = Instance.new("UIStroke", UI["5"])
  48. UI["6"]["Thickness"] = 3
  49.  
  50. -- // StarterGui.Basic Health GUI.Healthbar.UIStroke \ --
  51. UI["7"] = Instance.new("UIStroke", UI["2"])
  52. UI["7"]["Thickness"] = 3
  53. UI["7"]["Color"] = Color3.fromRGB(0, 81, 26)
  54.  
  55. -- // StarterGui.Basic Health GUI.Script \ --
  56. UI["8"] = Instance.new("Script", UI["1"])
  57.  
  58. -- // Notification Sending (Moved to Separate Thread) \ --
  59. task.spawn(function()
  60.     game:GetService("StarterGui"):SetCore("SendNotification", {
  61.         Title = "Made By bruhmoments#5852",
  62.         Text = "Healthbar Loaded!",
  63.         Duration = 10, -- Set a finite duration (infinite might not work)
  64.         Button1 = "Okay"
  65.     })
  66. end)
  67.  
  68. -- // StarterGui.Basic Health GUI.Healthbar.Healthbar.LocalScript \ --
  69. local function SCRIPT_4()
  70.     local script = UI["4"]
  71.     local P = game:GetService("Players").LocalPlayer -- LocalPlayer Variable
  72.     local C = P.Character or P.CharacterAdded:Wait() -- Character Variable
  73.     local H = C:WaitForChild("Humanoid") -- Humanoid Variable
  74.  
  75.     H.HealthChanged:connect(function()
  76.         script.Parent:TweenSize(UDim2.new(1/(H.MaxHealth/math.floor(H.Health + .5)),0,1,0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, .25)
  77.         script.Parent.Parent.percentage.Text = tostring(math.floor(100/(H.MaxHealth/H.Health)).."%")
  78.     end)
  79. end
  80. task.spawn(SCRIPT_4)
  81.  
  82. return UI["1"], require
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement