Advertisement
Gystac

cannonball

Jan 3rd, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. ball = script.Parent
  2. damage = 50
  3.  
  4. function onTouched(hit)
  5.  
  6.  
  7. local humanoid = hit.Parent:findFirstChild("Humanoid")
  8. if humanoid~=nil then
  9. tagHumanoid(humanoid)
  10. humanoid.Health = humanoid.Health - damage
  11. wait(2)
  12. untagHumanoid(humanoid)
  13. connection:disconnect()
  14. else
  15. damage = damage / 2
  16. if damage < 2 then
  17. connection:disconnect()
  18. ball.Parent = nil
  19. end
  20. end
  21.  
  22. if math.random(1,3) == 2 then
  23. explosion = Instance.new("Explosion")
  24. explosion.BlastRadius = 9
  25. explosion.BlastPressure = 1000000 -- these are really wussy units
  26. explosion.Position = script.Parent.Position
  27. explosion.Parent = game.Workspace
  28. connection:disconnect()
  29. ball.Parent = nil
  30. end
  31.  
  32. end
  33.  
  34. function tagHumanoid(humanoid)
  35. -- todo: make tag expire
  36. local tag = ball:findFirstChild("Gystac")
  37. if tag ~= nil then
  38. local new_tag = tag:clone()
  39. new_tag.Parent = humanoid
  40. end
  41. end
  42.  
  43.  
  44. function untagHumanoid(humanoid)
  45. if humanoid ~= nil then
  46. local tag = humanoid:findFirstChild("Gystac")
  47. if tag ~= nil then
  48. tag.Parent = nil
  49. end
  50. end
  51. end
  52.  
  53. connection = ball.Touched:connect(onTouched)
  54.  
  55. r = game:service("RunService")
  56. t, s = r.Stepped:wait()
  57. d = t + 5.0 - s
  58. while t < d do
  59. t = r.Stepped:wait()
  60. end
  61.  
  62. ball.Parent = nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement