ToxicOZ

Roblox hit indicator

Dec 8th, 2020 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. HITINDICATOR Put a script called "DamageIndicator" into "ServerScriptService"
  2. YT-ToxicOZ
  3.  
  4. local tweenService = game:GetService("TweenService")
  5.  
  6. local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
  7.  
  8. local damageForColours =
  9. {
  10. [25] = Color3.fromRGB(255, 196, 101),
  11. [50] = Color3.fromRGB(255, 234, 0),
  12. [75] = Color3.fromRGB(255, 140, 0),
  13. [100] = Color3.fromRGB(255, 0, 0),
  14. }
  15.  
  16. game.Players.PlayerAdded:Connect(function(plr)
  17.  
  18. plr.CharacterAdded:Connect(function(char)
  19.  
  20. local humanoid = char:WaitForChild("Humanoid")
  21. local currentHealth = humanoid.Health
  22.  
  23. humanoid.HealthChanged:Connect(function(health)
  24.  
  25. if health < currentHealth and humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
  26.  
  27. local healthLost = math.floor(currentHealth - health)
  28.  
  29.  
  30. local damageIndicatorGui = Instance.new("BillboardGui")
  31. damageIndicatorGui.AlwaysOnTop = true
  32.  
  33. damageIndicatorGui.Size = UDim2.new(1.5, 0, 1.5, 0)
  34.  
  35. local offsetX = math.random(-10, 10)/10
  36. local offsetY = math.random(-10, 10)/10
  37. local offsetZ = math.random(-10, 10)/10
  38. damageIndicatorGui.StudsOffset = Vector3.new(offsetX, offsetY, offsetZ)
  39.  
  40. local damageIndicatorLabel = Instance.new("TextLabel")
  41.  
  42. damageIndicatorLabel.AnchorPoint = Vector2.new(0.5, 0.5)
  43. damageIndicatorLabel.Position = UDim2.new(0.5, 0, 0.5, 0)
  44.  
  45. damageIndicatorLabel.TextScaled = true
  46. damageIndicatorLabel.BackgroundTransparency = 1
  47. damageIndicatorLabel.Font = Enum.Font.GothamBlack
  48.  
  49. damageIndicatorLabel.Text = healthLost
  50.  
  51. damageIndicatorLabel.Size = UDim2.new(0, 0, 0, 0)
  52.  
  53. for damage, colour in pairs(damageForColours) do
  54.  
  55. if healthLost <= damage then
  56.  
  57. damageIndicatorLabel.TextColor3 = colour
  58. damage = 100
  59. end
  60. end
  61.  
  62. damageIndicatorLabel.Parent = damageIndicatorGui
  63.  
  64. damageIndicatorGui.Parent = char.HumanoidRootPart
  65.  
  66. damageIndicatorLabel:TweenSize(UDim2.new(1, 0, 1, 0), "InOut", "Quint", 0.3)
  67.  
  68.  
  69. wait(0.3)
  70.  
  71. local guiUpTween = tweenService:Create(damageIndicatorGui, tweenInfo, {StudsOffset = damageIndicatorGui.StudsOffset + Vector3.new(0, 1, 0)})
  72.  
  73. local textFadeTween = tweenService:Create(damageIndicatorLabel, tweenInfo, {TextTransparency = 1})
  74.  
  75. guiUpTween:Play()
  76. textFadeTween:Play()
  77.  
  78. game:GetService("Debris"):AddItem(damageIndicatorGui, 0.3)
  79. end
  80.  
  81. currentHealth = humanoid.Health
  82. end)
  83. end)
  84. end)
  85.  
Advertisement
Add Comment
Please, Sign In to add comment