Advertisement
Navarone19_CH

PowerScript #1

Dec 5th, 2019
1,709
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.53 KB | None | 0 0
  1. local Bomb = {
  2. Tool = script.Parent,
  3. Handle = nil,
  4.  
  5. MinDamage = 50,
  6. MaxDamage = 50,
  7. FireRate = 0,
  8. BombVelocity = 125,
  9. ChargeTime = 10,
  10. ExtraSize = 10,
  11. Equipped = false,
  12. LastFlap = 10,
  13. StartChargeAt = 10,
  14. Charging = false
  15. }
  16.  
  17. local Debris = Game:GetService'Debris'
  18.  
  19. --
  20. --
  21. function Bomb.Validate()
  22. assert(Bomb.Tool:WaitForChild'Handle':IsA'BasePart', 'Failed to find handle')
  23. assert(Bomb.Tool:WaitForChild'StartCharge':IsA'RemoteEvent', 'Failed to find StartCharge RemoteEvent')
  24.  
  25. Bomb.Handle = Bomb.Tool.Handle
  26. end
  27. function Bomb.Initialize()
  28. end
  29. function Bomb.Start()
  30. Bomb.Validate()
  31. Bomb.Connect()
  32. Bomb.Initialize()
  33. end
  34. function Bomb.Connect()
  35. Bomb.Tool.Equipped:connect(Bomb.OnEquip)
  36. Bomb.Tool.Unequipped:connect(Bomb.OnUnequip)
  37.  
  38. Bomb.Tool.StartCharge.OnServerEvent:connect(Bomb.StartCharge)
  39. Bomb.Tool.StopCharge.OnServerEvent:connect(Bomb.StopCharge)
  40. end
  41. function Bomb.StopCharge(player, targetPos)
  42. if player.Character == Bomb.Tool.Parent then
  43. Bomb.ShotTarget = targetPos
  44. Bomb.Charging = false
  45. end
  46. end
  47. function Bomb.StartCharge(player)
  48. if player.Character == Bomb.Tool.Parent then
  49. local character = Bomb.Tool.Parent
  50. local head, humanoid = character:FindFirstChild'Head', character:FindFirstChild'Humanoid'
  51.  
  52. if head ~= nil and head:IsA'BasePart' and humanoid ~= nil and humanoid:IsA'Humanoid' then
  53. Bomb.StartChargeAt = tick()
  54. local lookAt = head.CFrame.lookVector
  55.  
  56. local mesh = Bomb.Handle:FindFirstChild'Mesh'
  57. if mesh and mesh:IsA'DataModelMesh' then
  58. mesh.Scale = Vector3.new(1,1,1)
  59. end
  60. local fire = Bomb.Handle:FindFirstChild'Fire'
  61. if fire and fire:IsA'Fire' then
  62. fire.Size = 0
  63. fire.Enabled = true
  64. end
  65.  
  66. local lastChargeSound = 0
  67. Bomb.Charging = true
  68.  
  69. while Bomb.Charging and Bomb.Equipped and tick()-Bomb.StartChargeAt < Bomb.ChargeTime and humanoid.Health > 0 do
  70. local alpha = (tick()-Bomb.StartChargeAt)/Bomb.ChargeTime
  71. Bomb.Handle.Transparency = 0.3+math.random()*0.3
  72. Bomb.Tool.GripPos = Vector3.new(0, 0, 0.5+Bomb.ExtraSize*0.5*alpha)
  73.  
  74. if mesh ~= nil then
  75. mesh.Scale = Vector3.new(1,1,1) + Vector3.new(1,1,1)*Bomb.ExtraSize*alpha
  76. end
  77. if fire ~= nil then
  78. fire.Size = alpha*Bomb.ExtraSize*2
  79. end
  80.  
  81. if tick() - lastChargeSound > 5 then
  82. lastChargeSound = tick()
  83.  
  84. local sound = Bomb.Handle:FindFirstChild'ChargeSound'
  85. if sound and sound:IsA'Sound' then
  86. sound:Play()
  87. end
  88. end
  89.  
  90. wait(0.5)
  91. end
  92.  
  93. Bomb.Tool.GripPos = Vector3.new()
  94. Bomb.Handle.Transparency = 1
  95.  
  96. local sound = Bomb.Handle:FindFirstChild'ChargeSound'
  97. if sound and sound:IsA'Sound' then
  98. sound:Stop()
  99. end
  100. local sound = Bomb.Handle:FindFirstChild'FireSound'
  101. if sound and sound:IsA'Sound' then
  102. sound:Play()
  103. end
  104. local fire = Bomb.Handle:FindFirstChild'Fire'
  105. if fire and fire:IsA'Fire' then
  106. fire.Enabled = false
  107. end
  108. local shot = Bomb.Handle:Clone()
  109. local fire = shot:FindFirstChild'Fire'
  110. if fire and fire:IsA'Fire' then
  111. fire.Enabled = true
  112. end
  113.  
  114. local alpha = math.min(math.max((tick()-Bomb.StartChargeAt)/Bomb.ChargeTime, 0), 1)
  115. local size = 1+ Bomb.ExtraSize*alpha
  116. shot.Size = Vector3.new(1,1,1)*size
  117. shot.Mesh.Scale = Vector3.new(1,1,1)*(size/shot.Size.Y)
  118. shot.Name = 'Effect'
  119. shot.CanCollide = false
  120. shot.Transparency = 0.4
  121. shot.Velocity = ((Bomb.ShotTarget - shot.Position).unit)*Bomb.BombVelocity
  122. shot.RotVelocity = Vector3.new(math.random()-.5,math.random()-.5,math.random()-.5)*2*10
  123. local force = Instance.new'BodyForce'
  124. force.force = Vector3.new(0, shot:GetMass()*196.2, 0)
  125. force.Parent = shot
  126.  
  127. shot.Touched:connect(function(hit)
  128. if shot~=nil and shot.Transparency ~= 1 and hit~=nil and hit.Name:lower():sub(1,6)~='effect' and hit.Name~='Handle' and hit.Name~='Water' then
  129. if not hit:IsDescendantOf(character) then
  130. local tCharacter = hit.Parent
  131. local tHumanoid = tCharacter:FindFirstChild'Humanoid'
  132.  
  133. if tHumanoid and tHumanoid:IsA'Humanoid' then
  134. local canHurtPlayer = true
  135.  
  136. local tPlayer = Game:GetService'Players':GetPlayerFromCharacter(tCharacter)
  137. if tPlayer and not tPlayer.Neutral and not player.Neutral and tPlayer.TeamColor==player.TeamColor then
  138. cnaHurtPlayer = false
  139. end
  140.  
  141. if canHurtPlayer then
  142. for index, obj in next, tHumanoid:GetChildren() do
  143. if obj.Name == 'creator' and obj:IsA'ObjectValue' then
  144. obj.Parent = nil
  145. end
  146. end
  147.  
  148. local tag = Instance.new'ObjectValue'
  149. tag.Name = 'creator'
  150. tag.Value = player
  151. tag.Parent = tHumanoid
  152.  
  153. tHumanoid:TakeDamage(Bomb.MinDamage + (Bomb.MaxDamage*Bomb.MinDamage)*alpha)
  154. local sound = shot:FindFirstChild'ExplodeSound'
  155. if sound ~= nil and sound:IsA'Sound' then
  156. sound.Volume = 0.5+0.5*alpha
  157. sound:Play()
  158. end
  159.  
  160. shot.Transparency = 1
  161. shot.Anchored = true
  162. local fire = shot:FindFirstChild'Fire'
  163. if fire and fire:IsA'Fire' then
  164. fire.Enabled = false
  165. end
  166. wait()
  167. if shot and shot.Parent then
  168. shot.Parent = nil
  169. end
  170. end
  171. end
  172. end
  173. end
  174. end)
  175.  
  176. Debris:AddItem(shot, 14)
  177. shot.Parent = workspace
  178. end
  179. end
  180. end
  181. function Bomb.OnEquip()
  182. Bomb.Equipped = true
  183. end
  184. function Bomb.OnUnequip()
  185. Bomb.Equipped = false
  186. end
  187.  
  188. --
  189. --
  190. Bomb.Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement