Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. local StarterGui = game:GetService("StarterGui")
  2. StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
  3.  
  4. local TweenService = game:GetService("TweenService")
  5. local Player = game.Players.LocalPlayer
  6. local Humanoid = Player.Character:WaitForChild("Humanoid")
  7. local Healthbar = script.Parent
  8. local Background = Healthbar.Background
  9. local Trail = Background.Trail
  10. local Green = Background.Trail.Green
  11. local TextLabel = Background.TextLabel
  12. local PreviousHealth = Humanoid.Health
  13. local Heart = Background.img_Heart
  14. local Count = 4
  15.  
  16. TextLabel.Text = Humanoid.Health.." / "..Humanoid.MaxHealth
  17. Background.Visible = true
  18. Green.Visible = true
  19. Trail.Visible = true
  20. Heart.Visible = true
  21. TextLabel.Visible = true
  22. TweenService:Create(Background, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = .7}):Play()
  23. TweenService:Create(Green, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 0}):Play()
  24. TweenService:Create(Trail, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 0}):Play()
  25. TweenService:Create(Heart, TweenInfo.new(.25, Enum.EasingStyle.Quint), {ImageTransparency = 0}):Play()
  26. TweenService:Create(TextLabel, TweenInfo.new(.25, Enum.EasingStyle.Quint), {TextTransparency = 0}):Play()
  27.  
  28. Humanoid.HealthChanged:Connect(function()
  29. if Humanoid.Health>=PreviousHealth*1.1 or Humanoid.Health<=PreviousHealth*.99 or Humanoid.Health<Humanoid.MaxHealth*.75 then
  30. Count = 4
  31. TweenService:Create(Background, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = .7}):Play()
  32. TweenService:Create(Green, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 0}):Play()
  33. TweenService:Create(Trail, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 0}):Play()
  34. TweenService:Create(Heart, TweenInfo.new(.25, Enum.EasingStyle.Quint), {ImageTransparency = 0}):Play()
  35. TweenService:Create(TextLabel, TweenInfo.new(.25, Enum.EasingStyle.Quint), {TextTransparency = 0}):Play()
  36. end
  37. if Humanoid.Health > Humanoid.MaxHealth then
  38. TweenService:Create(Heart, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {ImageColor3 = Color3.fromRGB(255,0,0)}):Play()
  39. Green:TweenSize(UDim2.new(1, 0, 1, 0), "Out", "Quad", .15+.35*Humanoid.Health/Humanoid.MaxHealth)
  40. TweenService:Create(Green, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {BackgroundColor3 = Color3.fromRGB(0,255,0)}):Play()
  41. Trail()
  42. TextLabel.Text = math.floor(Humanoid.Health).." / "..math.floor(Humanoid.MaxHealth)
  43. elseif Humanoid.Health <= 0 then
  44. TweenService:Create(Heart, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {ImageColor3 = Color3.fromRGB(0,0,0)}):Play()
  45. Green:TweenSize(UDim2.new(0, 0, 1, 0), "Out", "Quad", .15+.35*Humanoid.Health/Humanoid.MaxHealth)
  46. Trail()
  47. TweenService:Create(Green, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {BackgroundColor3 = Color3.fromRGB(0,170,0)}):Play()
  48. TextLabel.Text = "0 / "..math.floor(Humanoid.MaxHealth)
  49. else
  50. TweenService:Create(Heart, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {ImageColor3 = Color3.fromRGB(255*(Humanoid.Health/Humanoid.MaxHealth),0,0)}):Play()
  51. Green:TweenSize(UDim2.new(Humanoid.Health/Humanoid.MaxHealth, 0, 1, 0), "Out", "Quad", .15+.35*Humanoid.Health/Humanoid.MaxHealth)
  52. TweenService:Create(Green, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {BackgroundColor3 = Color3.fromRGB(170/(Humanoid.Health/Humanoid.MaxHealth),255*(Humanoid.Health/Humanoid.MaxHealth),0)}):Play()
  53. Trail()
  54. TextLabel.Text = math.floor(Humanoid.Health).." / "..math.floor(Humanoid.MaxHealth)
  55. end
  56. PreviousHealth=Humanoid.Health
  57. end)
  58.  
  59. while true do
  60. if Count <= 0 then
  61. TweenService:Create(Background, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 1}):Play()
  62. TweenService:Create(Green, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 1}):Play()
  63. TweenService:Create(Trail, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 1}):Play()
  64. TweenService:Create(Heart, TweenInfo.new(.25, Enum.EasingStyle.Quint), {ImageTransparency = 1}):Play()
  65. TweenService:Create(TextLabel, TweenInfo.new(.25, Enum.EasingStyle.Quint), {TextTransparency = 1}):Play()
  66. end
  67. Count = Count-1
  68. wait(1)
  69. end
  70.  
  71. function Trail()
  72. wait(1)
  73. print("Changed")
  74. --Trail:TweenSize(UDim2.new(1, 0, 1, 0), "Out", "Quad", .15+.35*Humanoid.Health/Humanoid.MaxHealth)
  75. --TweenService:Create(Trail, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {BackgroundColor3 = Color3.fromRGB(0,255,0)}):Play()
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement