-----------------

explosive grenade reupload

May 11th, 2021
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.38 KB | None | 0 0
  1. local plr = owner
  2. local char = plr.Character
  3. local hum = char:FindFirstChildOfClass("Humanoid")
  4. local torso = char:FindFirstChild("Torso") or char:FindFirstChild("HumanoidRootPart")
  5.  
  6. wait(0.1)
  7.  
  8. Tool0 = Instance.new("Tool")
  9. Part1 = Instance.new("Part")
  10. SpecialMesh2 = Instance.new("SpecialMesh")
  11. Tool0.Name = "Explosive Grenade"
  12. Tool0.CanBeDropped = false
  13. Tool0.Parent = plr:FindFirstChild("Backpack")
  14. Part1.Name = "Handle"
  15. Part1.Parent = Tool0
  16. Part1.Size = Vector3.new(0.798, 1.037, 0.791)
  17. Part1.BottomSurface = Enum.SurfaceType.Smooth
  18. Part1.Anchored = false
  19. Part1.CanCollide = false
  20. Part1.Material = Enum.Material.SmoothPlastic
  21. Part1.TopSurface = Enum.SurfaceType.Smooth
  22. Part1.Shape = Enum.PartType.Block
  23. Part1.CustomPhysicalProperties = PhysicalProperties.new(0.699999988, 1.5, 0.5, 2, 1)
  24. SpecialMesh2.Parent = Part1
  25. SpecialMesh2.MeshId = "rbxassetid://454821348"
  26. SpecialMesh2.Scale = Vector3.new(0.002, 0.002, 0.002)
  27. SpecialMesh2.TextureId = "rbxassetid://454821354"
  28. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  29.  
  30. local tool = Tool0
  31. local handle = Part1
  32.  
  33. local debris = game:GetService("Debris")
  34. local tween = game:GetService("TweenService")
  35.  
  36. local using = false
  37. local equipped = false
  38. local holding = false
  39. local amount = 1/0
  40.  
  41. local junk = script --workspace.junk
  42.  
  43. local hits = {1543854566,1543854764,1543854943,1543855404}
  44. local explosions = {2814354886,2814355346,2814355743,2814354338}
  45.  
  46. function play(id,par,vol,pitch,loop,starting,ending)
  47. local current = Instance.new("Sound",par)
  48. current.SoundId = "rbxassetid://" ..id
  49. current.Parent = par or script
  50. current.Volume = vol or 1
  51. current.PlaybackSpeed = pitch or 1
  52. current.Looped = loop or false
  53. current:Play()
  54. current.TimePosition = starting or 0
  55. spawn(function()
  56. if ending ~= nil and tonumber(ending) then
  57. repeat wait() until current.TimePositon >= ending
  58. current:Stop()
  59. debris:AddItem(current,1)
  60. else
  61. repeat wait() until not current.IsPlaying
  62. debris:AddItem(current,1)
  63. end
  64. end)
  65. return current
  66. end
  67.  
  68. local degrees = {
  69. CFrame.Angles(math.rad(45),math.rad(0),math.rad(0)),
  70. CFrame.Angles(math.rad(45),math.rad(45),math.rad(0)),
  71. CFrame.Angles(math.rad(0),math.rad(0),math.rad(45)),
  72. CFrame.Angles(math.rad(45),math.rad(0),math.rad(45)),
  73. CFrame.Angles(math.rad(45),math.rad(45),math.rad(0)),
  74. CFrame.Angles(math.rad(0),math.rad(45),math.rad(45)),
  75. CFrame.Angles(math.rad(45),math.rad(45),math.rad(45)),
  76. }
  77.  
  78. local blacklisted = {
  79. 'Base',
  80. 'Baseplate',
  81. }
  82.  
  83. function make_crater(size,cf,mode,ig)
  84. local subtract = {}
  85.  
  86. if mode == 1 then
  87. for i = 1,#degrees do
  88. local p = Instance.new("Part")
  89. p.Size = Vector3.new(size,size,size)
  90. p.Shape = Enum.PartType.Block
  91. p.Anchored = true
  92. p.CanCollide = false
  93. p.Transparency = 0.5
  94.  
  95. local angle = degrees[i]
  96. angle = math.random()
  97. p.CFrame = cf*angle
  98. p.Parent = game.Lighting
  99.  
  100. table.insert(subtract,1,p)
  101. end
  102. elseif mode == 2 then
  103. for i = 1,1 do
  104. local p = Instance.new("Part")
  105. p.Size = Vector3.new(size,size,size)
  106. p.Shape = Enum.PartType.Ball
  107. p.Anchored = true
  108. p.CanCollide = false
  109. p.Transparency = 0.5
  110.  
  111. p.CFrame = cf
  112. p.Parent = game.Lighting
  113.  
  114. table.insert(subtract,1,p)
  115. end
  116. elseif mode == 3 then
  117. for i = 1,10 do
  118. local p = Instance.new("Part")
  119. p.Size = Vector3.new(size,size,size)
  120. p.Shape = Enum.PartType.Block
  121. p.Anchored = true
  122. p.CanCollide = false
  123. p.Transparency = 0.5
  124.  
  125. local angle = CFrame.Angles(math.rad(math.random()*180),math.rad(math.random()*180),math.rad(math.random()*180))
  126. p.CFrame = cf*angle
  127. p.Parent = game.Lighting
  128.  
  129. table.insert(subtract,1,p)
  130. end
  131. end
  132.  
  133. assert(#subtract > 0,'No parts to union.')
  134. local region = Region3.new(cf.p-Vector3.new(size,size,size)/2,cf.p+Vector3.new(size,size,size)/2)
  135. local parts = workspace:FindPartsInRegion3WithIgnoreList(region,{unpack(subtract),unpack(ig)},1/0)
  136. for _,v in ipairs(parts) do
  137. if v and v:IsA("BasePart") and not v.Parent:IsA("Accessory") and not v.Parent:FindFirstChildOfClass("Humanoid") and not table.find(blacklisted,v.Name) then
  138. coroutine.wrap(function()
  139. local par = v.Parent
  140. v.Parent = game:GetService("Lighting")
  141. local union
  142. local success = pcall(function()
  143. union = v:SubtractAsync(subtract,Enum.CollisionFidelity.PreciseConvexDecomposition,Enum.RenderFidelity.Precise)
  144. end)
  145. if not union or not success then
  146. v:Destroy()
  147. return
  148. end
  149. union.Name = v.Name
  150. union.Anchored = v.Anchored
  151. union.CanCollide = v.CanCollide
  152. for _,vv in pairs(v:GetChildren()) do
  153. vv.Parent = union
  154. end
  155. v:Destroy()
  156. union.Parent = par
  157. end)()
  158. end
  159. end
  160. for i,v in ipairs(subtract) do v:Destroy() end
  161. end
  162.  
  163. function bang(par,pos)
  164. local Part0 = Instance.new("Part")
  165. local ParticleEmitter1 = Instance.new("ParticleEmitter")
  166. Part0.Name = "grenade"
  167. Part0.Parent = par
  168. Part0.Position = pos
  169. Part0.Transparency = 1
  170. Part0.Size = Vector3.new(4, 0.0500000007, 4)
  171. Part0.Anchored = true
  172. Part0.BottomSurface = Enum.SurfaceType.Smooth
  173. Part0.CanCollide = false
  174. Part0.Locked = true
  175. Part0.TopSurface = Enum.SurfaceType.Smooth
  176. ParticleEmitter1.Parent = Part0
  177. ParticleEmitter1.Speed = NumberRange.new(20,30)
  178. ParticleEmitter1.Color = ColorSequence.new(Color3.new(1,1,1),Color3.new(1,1,1))
  179. ParticleEmitter1.Enabled = false
  180. ParticleEmitter1.LightEmission = 0.80000001192093
  181. ParticleEmitter1.Texture = "rbxassetid://3607612871"
  182. ParticleEmitter1.Size = NumberSequence.new(3,0.5)
  183. ParticleEmitter1.Lifetime = NumberRange.new(0.80000001192093, 0.80000001192093)
  184. ParticleEmitter1.LockedToPart = true
  185. ParticleEmitter1.Rate = 10000
  186. ParticleEmitter1.RotSpeed = NumberRange.new(270, 270)
  187. ParticleEmitter1.SpreadAngle = Vector2.new(-90, -90)
  188. ParticleEmitter1.VelocitySpread = -90
  189. play(explosions[math.random(1,#explosions)],Part0,1)
  190.  
  191. local ex = Instance.new("Explosion")
  192. ex.Parent = junk
  193. ex.Visible = false
  194. ex.Position = pos
  195. ex.DestroyJointRadiusPercent = 0
  196. ex.BlastRadius = 20
  197. ex.BlastPressure = 0
  198. spawn(function()
  199. make_crater(20/2,CFrame.new(pos),3,{Part0,par})
  200. end)
  201. ex.Hit:connect(function(obj, Distance)
  202. if ex.BlastRadius >= Distance then else return end
  203. local targchar,tarhum,targtorso,targhead
  204. pcall(function()
  205. targchar = obj.Parent
  206. end)
  207. pcall(function()
  208. tarhum = targchar:FindFirstChildOfClass("Humanoid")
  209. end)
  210. pcall(function()
  211. targtorso = targchar:FindFirstChild("HumanoidRootPart") or targchar:FindFirstChild("Torso")
  212. end)
  213. pcall(function()
  214. targhead = targchar:FindFirstChild("Head")
  215. end)
  216. if targchar and targhead --[[and (targplr.TeamColor ~= plr.TeamColor or targplr == plr)]] and tarhum and tarhum.Parent and targtorso and targtorso.Parent then
  217. local p1 = pos+Vector3.new(0,1,0)
  218. local p2 = (targhead.Position-p1)
  219. local chars = {}
  220. for i,v in pairs(workspace:GetChildren()) do
  221. local targchar2,tarhum2,targtorso2
  222. pcall(function()
  223. targchar2 = obj.Parent
  224. end)
  225. pcall(function()
  226. tarhum2 = targchar2:FindFirstChildOfClass("Humanoid")
  227. end)
  228. pcall(function()
  229. targtorso2 = targchar2:FindFirstChild("HumanoidRootPart") or targchar2:FindFirstChild("Torso")
  230. end)
  231. if targchar2 and tarhum2 and tarhum2.Parent and targtorso2 and targtorso2.Parent then
  232. table.insert(chars,#chars+1,targchar2)
  233. end
  234. end
  235. local params = RaycastParams.new()
  236. params.IgnoreWater = true
  237. params.FilterType = Enum.RaycastFilterType.Blacklist
  238. params.FilterDescendantsInstances = {script,Part0,targchar,unpack(chars),junk}
  239. local blocked = false
  240. local hit = workspace:Raycast(
  241. p1,
  242. p2.Unit*p2.Magnitude,
  243. params
  244. )
  245. if hit and 0.5 > hit.Instance.Transparency then
  246. --[[
  247. print(hit)
  248. local paa = Instance.new("Part",workspace)
  249. paa.Size = Vector3.new(1,1,1)
  250. paa.CanCollide = false
  251. paa.Anchored = true
  252. paa.Transparency = 0
  253. paa.Position = hit.Position
  254. ]]
  255. blocked = true
  256. end
  257. if not blocked and not tarhum:FindFirstChild("hit grenade " .. plr.Name) then
  258. local cval = Instance.new("ObjectValue",tarhum)
  259. cval.Name = ("hit grenade " .. plr.Name)
  260. cval.Parent = tarhum
  261. game:GetService("Debris"):AddItem(cval,0.3)
  262. tarhum:TakeDamage((1-(Distance/ex.BlastRadius))*150)
  263. if 0 >= tarhum.Health and not tarhum:FindFirstChild("killer") then
  264. local tempkillval = Instance.new("ObjectValue",tarhum)
  265. tempkillval.Name = "killer"
  266. tempkillval.Value = plr
  267. end
  268. end
  269. end
  270. end)
  271. spawn(function()
  272. ParticleEmitter1.Enabled = true
  273. wait(.25)
  274. ParticleEmitter1.Enabled = false
  275. debris:AddItem(Part0,1)
  276. debris:AddItem(ex,1)
  277. end)
  278. end
  279.  
  280. function throw(mpos)
  281. local pag = Instance.new("Part")
  282. pag.Parent = junk
  283. pag.CanCollide = false
  284. pag.Transparency = 1
  285. pag.Anchored = true
  286. pag.CanCollide = false
  287. pag.CFrame = CFrame.new(handle.Position,mpos)
  288.  
  289. --play('2552683979',torso,1)
  290. play('711753382',handle,1)
  291.  
  292. local fake = handle:Clone()
  293. fake.Parent = junk
  294. fake.Name = "grenade"
  295. fake.CanCollide = true
  296. fake.Velocity = pag.CFrame.lookVector * 130
  297.  
  298. local hit = Instance.new("Sound")
  299. hit.SoundId = "rbxassetid://" .. tostring(hits[math.random(1,#hits)])
  300. hit.Parent = fake
  301. hit.Volume = 1
  302.  
  303. local bouncing = false
  304. local activated = false
  305.  
  306. fake.Touched:Connect(function(obj)
  307. if obj and not bouncing then
  308. bouncing = true
  309. hit.SoundId = "rbxassetid://2552566004"-- .. tostring(hits[math.random(1,#hits)])
  310. hit:Play()
  311. spawn(function()
  312. wait(.1)
  313. bouncing = false
  314. end)
  315. if not activated then
  316. activated = true
  317. spawn(function()
  318. wait(2)
  319. bang(junk,fake.Position)
  320. fake:Destroy()
  321. pag:Destroy()
  322. end)
  323. end
  324. end
  325. end)
  326. end
  327.  
  328. tool.Equipped:Connect(function()
  329. equipped = true
  330. end)
  331. tool.Unequipped:Connect(function()
  332. equipped = false
  333. end)
  334.  
  335. local remote = script:FindFirstChild('RemoteEvent') or Instance.new("RemoteEvent")
  336. remote.Parent = plr:FindFirstChildOfClass("Backpack")
  337.  
  338. remote.OnServerEvent:Connect(function(lplr,data)
  339. if plr == lplr and data then else return end
  340. if equipped and not using then
  341. using = true
  342. throw(data)
  343. amount -= 1
  344. if 0 >= amount then
  345. tool:Destroy()
  346. end
  347. wait(0.25)
  348. using = false
  349. end
  350. end)
  351.  
  352. NLS([[
  353. local mouse = game:GetService("Players").LocalPlayer:GetMouse()
  354. local remote = script.Parent
  355. mouse.Button1Down:Connect(function()
  356. remote:FireServer(mouse.Hit.p)
  357. end)
  358. ]],remote)
Advertisement
Add Comment
Please, Sign In to add comment