KrYn0MoRe

explosive nade

Nov 27th, 2020 (edited)
874
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. function bang(par,pos)
  69.     local Part0 = Instance.new("Part")
  70.     local ParticleEmitter1 = Instance.new("ParticleEmitter")
  71.     Part0.Name = "grenade"
  72.     Part0.Parent = par
  73.     Part0.Position = pos
  74.     Part0.Transparency = 1
  75.     Part0.Size = Vector3.new(4, 0.0500000007, 4)
  76.     Part0.Anchored = true
  77.     Part0.BottomSurface = Enum.SurfaceType.Smooth
  78.     Part0.CanCollide = false
  79.     Part0.Locked = true
  80.     Part0.TopSurface = Enum.SurfaceType.Smooth
  81.     ParticleEmitter1.Parent = Part0
  82.     ParticleEmitter1.Speed = NumberRange.new(20,30)
  83.     ParticleEmitter1.Color = ColorSequence.new(Color3.new(1,1,1),Color3.new(1,1,1))
  84.     ParticleEmitter1.Enabled = false
  85.     ParticleEmitter1.LightEmission = 0.80000001192093
  86.     ParticleEmitter1.Texture = "rbxassetid://3607612871"
  87.     ParticleEmitter1.Size = NumberSequence.new(3,0.5)
  88.     ParticleEmitter1.Lifetime = NumberRange.new(0.80000001192093, 0.80000001192093)
  89.     ParticleEmitter1.LockedToPart = true
  90.     ParticleEmitter1.Rate = 10000
  91.     ParticleEmitter1.RotSpeed = NumberRange.new(270, 270)
  92.     ParticleEmitter1.SpreadAngle = Vector2.new(-90, -90)
  93.     ParticleEmitter1.VelocitySpread = -90
  94.     play(explosions[math.random(1,#explosions)],Part0,1)
  95.     local ex = Instance.new("Explosion")
  96.     ex.Parent = junk
  97.     ex.Visible = false
  98.     ex.Position = pos
  99.     ex.DestroyJointRadiusPercent = 0
  100.     ex.BlastRadius = 20
  101.     ex.BlastPressure = 0
  102.     ex.Hit:connect(function(obj, Distance)
  103.         if ex.BlastRadius >= Distance then else return end
  104.         local targchar,tarhum,targtorso,targhead
  105.         pcall(function()
  106.             targchar = obj.Parent
  107.         end)
  108.         pcall(function()
  109.             tarhum = targchar:FindFirstChildOfClass("Humanoid")
  110.         end)
  111.         pcall(function()
  112.             targtorso = targchar:FindFirstChild("HumanoidRootPart") or targchar:FindFirstChild("Torso")
  113.         end)
  114.         pcall(function()
  115.             targhead = targchar:FindFirstChild("Head")
  116.         end)
  117.         if targchar and targhead --[[and (targplr.TeamColor ~= plr.TeamColor or targplr == plr)]] and tarhum and tarhum.Parent and targtorso and targtorso.Parent then
  118.             local p1 = pos+Vector3.new(0,1,0)
  119.             local p2 = (targhead.Position-p1)
  120.             local chars = {}
  121.             for i,v in pairs(workspace:GetChildren()) do
  122.                 local targchar2,tarhum2,targtorso2
  123.                 pcall(function()
  124.                     targchar2 = obj.Parent
  125.                 end)
  126.                 pcall(function()
  127.                     tarhum2 = targchar2:FindFirstChildOfClass("Humanoid")
  128.                 end)
  129.                 pcall(function()
  130.                     targtorso2 = targchar2:FindFirstChild("HumanoidRootPart") or targchar2:FindFirstChild("Torso")
  131.                 end)
  132.                 if targchar2 and tarhum2 and tarhum2.Parent and targtorso2 and targtorso2.Parent then
  133.                     table.insert(chars,#chars+1,targchar2)
  134.                 end
  135.             end
  136.             local params = RaycastParams.new()
  137.             params.IgnoreWater = true
  138.             params.FilterType = Enum.RaycastFilterType.Blacklist
  139.             params.FilterDescendantsInstances = {script,Part0,targchar,unpack(chars),junk}
  140.             local blocked = false
  141.             local hit = workspace:Raycast(
  142.                 p1,
  143.                 p2.Unit*p2.Magnitude,
  144.                 params
  145.             )
  146.             if hit and 0.5 > hit.Instance.Transparency then
  147.                 --[[
  148.                 print(hit)
  149.                 local paa = Instance.new("Part",workspace)
  150.                 paa.Size = Vector3.new(1,1,1)
  151.                 paa.CanCollide = false
  152.                 paa.Anchored = true
  153.                 paa.Transparency = 0
  154.                 paa.Position = hit.Position
  155.                 ]]
  156.                 blocked = true
  157.             end
  158.             if not blocked and not tarhum:FindFirstChild("hit grenade " .. plr.Name) then
  159.                 local cval = Instance.new("ObjectValue",tarhum)
  160.                 cval.Name = ("hit grenade " .. plr.Name)
  161.                 cval.Parent = tarhum
  162.                 game:GetService("Debris"):AddItem(cval,0.3)
  163.                 tarhum:TakeDamage((1-(Distance/ex.BlastRadius))*150)
  164.                 if 0 >= tarhum.Health and not tarhum:FindFirstChild("killer") then
  165.                     local tempkillval = Instance.new("ObjectValue",tarhum)
  166.                     tempkillval.Name = "killer"
  167.                     tempkillval.Value = plr
  168.                 end
  169.             end
  170.         end
  171.     end)
  172.     spawn(function()
  173.         ParticleEmitter1.Enabled = true
  174.         wait(.25)
  175.         ParticleEmitter1.Enabled = false
  176.         debris:AddItem(Part0,1)
  177.         debris:AddItem(ex,1)
  178.     end)
  179. end
  180.  
  181. function throw(mpos)
  182.     local pag = Instance.new("Part")
  183.     pag.Parent = junk
  184.     pag.CanCollide = false
  185.     pag.Transparency = 1
  186.     pag.Anchored = true
  187.     pag.CanCollide = false
  188.     pag.CFrame = CFrame.new(handle.Position,mpos)
  189.    
  190.     --play('2552683979',torso,1)
  191.     play('711753382',handle,1)
  192.  
  193.     local fake = handle:Clone()
  194.     fake.Parent = junk
  195.     fake.Name = "grenade"
  196.     fake.CanCollide = true
  197.     fake.Velocity = pag.CFrame.lookVector * 130
  198.    
  199.     local hit = Instance.new("Sound")
  200.     hit.SoundId = "rbxassetid://" .. tostring(hits[math.random(1,#hits)])
  201.     hit.Parent = fake
  202.     hit.Volume = 1
  203.    
  204.     local bouncing = false
  205.     local activated = false
  206.    
  207.     fake.Touched:Connect(function(obj)
  208.         if obj and not bouncing then
  209.             bouncing = true
  210.             hit.SoundId = "rbxassetid://2552566004"-- .. tostring(hits[math.random(1,#hits)])
  211.             hit:Play()
  212.             spawn(function()
  213.                 wait(.1)
  214.                 bouncing = false
  215.             end)
  216.             if not activated then
  217.                 activated = true
  218.                 spawn(function()
  219.                     wait(2)
  220.                     bang(junk,fake.Position)
  221.                     fake:Destroy()
  222.                     pag:Destroy()
  223.                 end)
  224.             end
  225.         end
  226.     end)
  227. end
  228.  
  229. tool.Equipped:Connect(function()
  230.     equipped = true
  231. end)
  232. tool.Unequipped:Connect(function()
  233.     equipped = false
  234. end)
  235.  
  236. local remote = script:FindFirstChild('RemoteEvent') or Instance.new("RemoteEvent")
  237. remote.Parent = plr:FindFirstChildOfClass("Backpack")
  238.  
  239. remote.OnServerEvent:Connect(function(lplr,data)
  240.     if plr == lplr and data then else return end
  241.     if equipped and not using then
  242.         using = true
  243.         throw(data)
  244.         amount -= 1
  245.         if 0 >= amount then
  246.             tool:Destroy()
  247.         end
  248.         wait(0.25)
  249.         using = false
  250.     end
  251. end)
  252.  
  253. NLS([[
  254. local mouse = game:GetService("Players").LocalPlayer:GetMouse()
  255. local remote = script.Parent
  256. mouse.Button1Down:Connect(function()
  257.     remote:FireServer(mouse.Hit.p)
  258. end)
  259. ]],remote)
RAW Paste Data