Advertisement
P_YStudio

Health Bar Roblox Studio

Jul 22nd, 2023
2,904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. local HealthBarColor = Color3.fromRGB(125, 255, 78)
  2.  
  3. local HealthBar = Instance.new("Frame")
  4. HealthBar.Parent = script.Parent
  5. HealthBar.Position = UDim2.new(0,0,0,0)
  6. HealthBar.BorderSizePixel = 0
  7. HealthBar.Size = script.Parent.Size
  8. HealthBar.BackgroundColor3 = HealthBarColor
  9.  
  10. local Humanoid = script:FindFirstAncestorWhichIsA("Player").Character:WaitForChild("Humanoid")
  11.  
  12. Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
  13.  
  14.    
  15.     HealthBar.Size = UDim2.new(HealthBar.Size.X.Scale,Humanoid.Health * script.Parent.AbsoluteSize.X / 100,HealthBar.Size.Y.Scale,HealthBar.Size.Y.Offset)
  16.  
  17. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement