Advertisement
killerboy634

xD

Jun 23rd, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. --clockwork
  2.  
  3. --Fix implemented by Luckymaxer
  4.  
  5. HopperBin = script.Parent
  6.  
  7. Sound = HopperBin:WaitForChild("Sound")
  8.  
  9. Debris = game:GetService("Debris")
  10.  
  11. function TagHumanoid(humanoid, player)
  12. local Creator_Tag = Instance.new("ObjectValue")
  13. Creator_Tag.Name = "creator"
  14. Creator_Tag.Value = player
  15. Debris:AddItem(Creator_Tag, 2)
  16. Creator_Tag.Parent = humanoid
  17. end
  18.  
  19. function UntagHumanoid(humanoid)
  20. for i, v in pairs(humanoid:GetChildren()) do
  21. if v:IsA("ObjectValue") and v.Name == "creator" then
  22. v:Destroy()
  23. end
  24. end
  25. end
  26.  
  27. function FindCharacterAncestor(Parent)
  28. if Parent and Parent ~= game:GetService("Workspace") then
  29. local humanoid = Parent:FindFirstChild("Humanoid")
  30. if humanoid then
  31. return Parent, humanoid
  32. else
  33. return FindCharacterAncestor(Parent.Parent)
  34. end
  35. end
  36. return nil
  37. end
  38.  
  39. function ExplosionHit(Explosion)
  40. Explosion.Hit:connect(function(Hit)
  41. if Hit and Hit.Parent then
  42. local character, humanoid = FindCharacterAncestor(Hit)
  43. if character and character ~= Character and humanoid and humanoid.Health > 0 then
  44. UntagHumanoid(humanoid)
  45. TagHumanoid(humanoid, Player)
  46. Hit:BreakJoints()
  47. end
  48. end
  49. end)
  50. end
  51.  
  52. function Explode(Position)
  53. local Explosion = Instance.new("Explosion")
  54. Explosion.BlastRadius = 10
  55. Explosion.BlastPressure = 0
  56. Explosion.ExplosionType = Enum.ExplosionType.NoCraters
  57. Explosion.Position = Position
  58. ExplosionHit(Explosion)
  59. Explosion.Parent = game:GetService("Workspace")
  60. end
  61.  
  62. function Button1Down(Mouse)
  63. local StartPos = Head.Position
  64. local Delta = Mouse.Hit.p - StartPos
  65. local Unit = Delta.unit
  66. Sound:Play()
  67. for i = 0, 75 do
  68. Explode(StartPos + Unit * 20 + i * Unit * i / 25)
  69. wait(0.05)
  70. end
  71. end
  72.  
  73. function Selected(Mouse)
  74. Backpack = HopperBin.Parent
  75. Player = Backpack.Parent
  76. Character = Player.Character
  77. Humanoid = Character:FindFirstChild("Humanoid")
  78. Head = Character:FindFirstChild("Head")
  79. if not Player or not Character or not Humanoid or Humanoid.Health == 0 or not Head then
  80. return
  81. end
  82. Mouse.Button1Down:connect(function()
  83. Button1Down(Mouse)
  84. end)
  85. Mouse.Icon = "rbxasset://textures\\GunCursor.png"
  86. end
  87.  
  88. HopperBin.Selected:connect(Selected)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement