NEON_YouTube

HPBar

Jan 16th, 2023 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. -- HPBar
  2. -- Version: 0.0.1
  3. -- By pawela827
  4.  
  5. local HealthBar = Instance.new("ScreenGui")
  6. local HealthFrame = Instance.new("Frame")
  7. local Bar = Instance.new("Frame")
  8. local HealthText = Instance.new("TextLabel")
  9.  
  10.  
  11.  
  12. HealthBar.Name = "Health Bar"
  13. HealthBar.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  14.  
  15. HealthFrame.Name = "HealthFrame"
  16. HealthFrame.Parent = HealthBar
  17. HealthFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  18. HealthFrame.BackgroundTransparency = 0.500
  19. HealthFrame.LayoutOrder = 1
  20. HealthFrame.Position = UDim2.new(0, 5, 0, 100)
  21. HealthFrame.Size = UDim2.new(0, 200, 0, 40)
  22.  
  23. Bar.Name = "Bar"
  24. Bar.Parent = HealthFrame
  25. Bar.BackgroundColor3 = Color3.fromRGB(85, 255, 0)
  26. Bar.Size = UDim2.new(0, 200, 0, 40)
  27.  
  28. HealthText.Name = "HealthText"
  29. HealthText.Parent = HealthFrame
  30. HealthText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  31. HealthText.BackgroundTransparency = 1.000
  32. HealthText.Size = UDim2.new(1, 0, 1, 0)
  33. HealthText.Font = Enum.Font.SourceSansBold
  34. HealthText.Text = "HP: 100/100"
  35. HealthText.TextColor3 = Color3.fromRGB(255, 255, 255)
  36. HealthText.TextSize = 24.000
  37. HealthText.TextWrapped = true
  38.  
  39.  
  40.  
  41. local function _script()
  42.     local script = Instance.new('Script', HealthBar)
  43.  
  44.     game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false)
  45.    
  46.  
  47.     local player = game.Players.LocalPlayer
  48.     local char = player.Character
  49.     local gui = script.Parent
  50.     local frame = gui.HealthFrame
  51.     local bar = frame.Bar
  52.     local text = frame.HealthText
  53.    
  54.     while wait() do
  55.  
  56.     text.Text = "HP: "..math.floor(char:WaitForChild("Humanoid").Health).."/"..char:WaitForChild("Humanoid").MaxHealth
  57.  
  58.     bar.Size = UDim2.new(0,(char:WaitForChild("Humanoid").Health / char:WaitForChild("Humanoid").MaxHealth * 200),1,0)
  59.     end
  60. end
  61. coroutine.wrap(_script)()
  62.  
Advertisement
Add Comment
Please, Sign In to add comment