Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local zombie = script.Parent
- local humanoid = zombie:FindFirstChildOfClass("Humanoid")
- if not humanoid then
- warn("No Humanoid found in the Zombie")
- return
- end
- local billboardGui = zombie:FindFirstChild("BillboardGui")
- if not billboardGui then
- billboardGui = Instance.new("BillboardGui")
- billboardGui.Name = "BillboardGui"
- billboardGui.Size = UDim2.new(0, 200, 0, 50)
- billboardGui.Adornee = zombie
- billboardGui.Parent = zombie
- end
- local healthBar = billboardGui:FindFirstChild("HealthBar")
- if not healthBar then
- healthBar = Instance.new("Frame")
- healthBar.Name = "HealthBar"
- healthBar.Size = UDim2.new(1, 0, 1, 0)
- healthBar.BackgroundColor3 = Color3.new(0, 1, 0)
- healthBar.Parent = billboardGui
- end
- local function updateHealthBar()
- local healthPercentage = humanoid.Health / humanoid.MaxHealth
- healthBar.Size = UDim2.new(healthPercentage, 0, 1, 0)
- healthBar.BackgroundColor3 = Color3.fromRGB(
- 255 * (1 - healthPercentage),
- 255 * healthPercentage,
- 0
- )
- end
- while true do
- updateHealthBar()
- wait(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement