Advertisement
LordJunes

Untitled

Sep 8th, 2024
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | Gaming | 0 0
  1. local zombie = script.Parent
  2. local humanoid = zombie:FindFirstChildOfClass("Humanoid")
  3.  
  4. if not humanoid then
  5.     warn("No Humanoid found in the Zombie")
  6.     return
  7. end
  8.  
  9. local billboardGui = zombie:FindFirstChild("BillboardGui")
  10. if not billboardGui then
  11.     billboardGui = Instance.new("BillboardGui")
  12.     billboardGui.Name = "BillboardGui"
  13.     billboardGui.Size = UDim2.new(0, 200, 0, 50)
  14.     billboardGui.Adornee = zombie
  15.     billboardGui.Parent = zombie
  16. end
  17.  
  18. local healthBar = billboardGui:FindFirstChild("HealthBar")
  19. if not healthBar then
  20.     healthBar = Instance.new("Frame")
  21.     healthBar.Name = "HealthBar"
  22.     healthBar.Size = UDim2.new(1, 0, 1, 0)
  23.     healthBar.BackgroundColor3 = Color3.new(0, 1, 0)
  24.     healthBar.Parent = billboardGui
  25. end
  26.  
  27. local function updateHealthBar()
  28.     local healthPercentage = humanoid.Health / humanoid.MaxHealth
  29.     healthBar.Size = UDim2.new(healthPercentage, 0, 1, 0)
  30.     healthBar.BackgroundColor3 = Color3.fromRGB(
  31.         255 * (1 - healthPercentage),
  32.         255 * healthPercentage,
  33.         0
  34.     )
  35. end
  36.  
  37. while true do
  38.     updateHealthBar()
  39.     wait(1)
  40. end
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement