Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. wait(2)
  2. local plr = game.Players.LocalPlayer
  3. local char = plr.Character
  4. local humanoid = char:FindFirstChild("Humanoid")
  5. local image = script.Parent.Image
  6. local health = humanoid.Health
  7.  
  8. local function onHealthChanged()
  9. if health == 0 then
  10. script.Parent.Image = "http://www.roblox.com/asset/?id=3326061588"
  11. elseif health > 0 and health < 33 then
  12. script.Parent.Image = "http://www.roblox.com/asset/?id=3326061097"
  13. elseif health > 33 and health < 66 then
  14. script.Parent.Image = "http://www.roblox.com/asset/?id=3326059493"
  15. elseif health > 66 then
  16. script.Parent.Image = "http://www.roblox.com/asset/?id=3326058976"
  17. end
  18. end
  19.  
  20. local function onCharacterAdded(character)
  21. local human = character:WaitForChild("Humanoid")
  22. -- Pattern: update once now, then any time the health changes
  23. human.HealthChanged:Connect(onHealthChanged)
  24. onHealthChanged()
  25. end
  26.  
  27. plr.CharacterAdded:Connect(onCharacterAdded)
  28. if plr.Character then
  29. onCharacterAdded(plr.Character)
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement