squidingtin

Dubstep Gun?

Aug 4th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. local new=Instance.new
  2. local rad=math.rad
  3. local cf=CFrame.new
  4. local v3=Vector3.new
  5. local ang=function(x,y,z)
  6. return CFrame.Angles(rad(x),rad(y),rad(z))
  7. end
  8. local player=game:service'Players'.LocalPlayer
  9. local char=player.Character
  10. local cam=workspace.Camera
  11. local mouse=player:GetMouse()
  12. local weld=function(a,b,c0,c1)
  13. m=Instance.new('Motor',a)
  14. m.Part0=a
  15. m.Part1=b
  16. m.C0=c0
  17. m.C1=c1
  18. return m
  19. end
  20.  
  21. snd='rbxassetid://130768080'
  22. beamm=Instance.new('Model',workspace)
  23. beamm.Name='beam'
  24.  
  25. laser=false
  26.  
  27. rs=Instance.new('Part',char)
  28. rs.Transparency=1
  29. rs.CanCollide=false
  30. rs.TopSurface,rs.BottomSurface=0,0
  31. rs.FormFactor=3
  32. rs.Size=Vector3.new(.5,.5,.5)
  33.  
  34. ls=rs:Clone()
  35. ls.Parent=char
  36.  
  37. rsw=weld(rs,char.Torso,cf(-1,-.5,0),cf())
  38. lsw=weld(ls,char.Torso,cf(1,-.5,0),cf())
  39. raw=weld(char['Right Arm'],rs,cf(-.5,.6,-.14),ang(90,0,-8))
  40. law=weld(char['Left Arm'],ls,cf(-.3,1.5,-.14),ang(90,0,43))
  41.  
  42. s1=Instance.new('Sound',char)
  43. s1.Volume=1
  44. s1.Pitch=1
  45. s1.Looped=true
  46. s1.SoundId=snd
  47.  
  48. particles={}
  49.  
  50. local wep=new('Part',char)
  51. wep.FormFactor=3
  52. wep.CanCollide=false
  53. wep.Size=v3(1,3,1)
  54. wep.TopSurface,wep.BottomSurface=0,0
  55. local wepw=weld(wep,char['Right Arm'],cf(.26,.4,.7),ang(0,0,8))
  56.  
  57. local beam=wep:Clone()
  58. beam:ClearAllChildren()
  59. beam.Material='Neon'
  60. beam.BrickColor=BrickColor.new('Toothpaste')
  61. beam.Size=Vector3.new(3,3,1)
  62. beam.Transparency=.5
  63. beam.Anchored=true
  64. local ms=Instance.new('BlockMesh',beam)
  65. local inner=beam:Clone()
  66. inner.Transparency=0
  67. inner.Material='SmoothPlastic'
  68. inner.BrickColor=BrickColor.new('Navy blue')
  69. local ms2=inner.Mesh
  70.  
  71. local expl=inner:Clone()
  72. expl.Mesh:Destroy()
  73. expl.Material='Neon'
  74. expl.BrickColor=BrickColor.new('Toothpaste')
  75. expl.Size=Vector3.new(11,11,11)
  76. expl.Transparency=.55
  77. pl=Instance.new('PointLight',expl)
  78. pl.Color=expl.BrickColor.Color
  79. pl.Range=pl.Range*2
  80. pl.Name='light'
  81. local br=pl.Range
  82.  
  83. local exa=expl:Clone()
  84. exa.Size=Vector3.new(4,4,4)
  85. pl2=exa.light
  86.  
  87. local part=exa:Clone()
  88. part.Size=Vector3.new(1.5,1.5,1.5)
  89. pl3=part.light
  90. pms=Instance.new('BlockMesh',part)
  91.  
  92. char.Humanoid.Died:connect(function()
  93. laser=false
  94. beam.Parent=nil
  95. inner.Parent=nil
  96. expl.Parent=nil
  97. exa.Parent=nil
  98. s1:stop()
  99. end)
  100.  
  101. mouse.Button1Down:connect(function() if char.Humanoid.Health~=0 then
  102. laser=true
  103. s1.Volume=1
  104. s1:play()
  105. end end)
  106. mouse.Button1Up:connect(function()
  107. laser=false
  108. beam.Parent=nil
  109. inner.Parent=nil
  110. expl.Parent=nil
  111. exa.Parent=nil
  112. s1:stop()
  113. end)
  114.  
  115. parti=0
  116. game:service'RunService'.Stepped:connect(function()
  117. parti=parti+1
  118. for i,v in pairs(particles) do
  119. v.CFrame=v.CFrame*CFrame.new(0,0,-.3)
  120. v.Transparency=v.Transparency+.08
  121. if v.Transparency >= 1 then
  122. v:Destroy()
  123. table.remove(particles,i)
  124. else
  125. v.Parent=beamm
  126. end
  127. end
  128. a=cam.CoordinateFrame.p
  129. b=mouse.Hit.p
  130. mhitr=Ray.new(a,(b-a).unit*999)
  131. mhit,ps=workspace:FindPartOnRayWithIgnoreList(mhitr,{char,beamm})
  132. raw.C1=ang(90+(mouse.Hit.lookVector.y*90),0,-8)
  133. law.C1=ang(90+(mouse.Hit.lookVector.y*90),0,43)
  134. if not char.Humanoid.Sit and not char.Humanoid.PlatformStand then
  135. char.Torso.CFrame=CFrame.new(char.Torso.CFrame.p,Vector3.new(ps.x,char.Torso.CFrame.p.y,ps.z))
  136. end
  137. if laser then
  138. beamm.Parent=workspace
  139. beam.Parent=beamm
  140. inner.Parent=beamm
  141. expl.Parent=beamm
  142. exa.Parent=beamm
  143. s1.Volume=s1.Volume-.002
  144.  
  145. ray=Ray.new((wep.CFrame*cf(0,-1.5,0)).p,((wep.CFrame*cf(0,-10,0)).p-(wep.CFrame*cf(0,-1.5,0)).p).unit*999)
  146. hit,pos=workspace:FindPartOnRayWithIgnoreList(ray,{char,beamm})
  147.  
  148. if hit and hit.Parent:findFirstChild('Humanoid') and s1.Volume > .3 and parti/8==math.floor(parti/8) then
  149. Instance.new('Explosion',workspace).Position=pos
  150. end
  151. if hit and hit.Parent==workspace.Terrain or hit==workspace.Terrain and parti/8==math.floor(parti/8) then
  152. e=Instance.new('Explosion',workspace)
  153. e.Position=pos
  154. e.BlastRadius=14
  155. e.BlastPressure=1e4
  156. end
  157. if hit and not hit.Anchored and not (hit:GetMass()>1e4) then
  158. hit.Velocity=hit.Velocity+beam.CFrame.lookVector*(1*s1.Volume*hit:GetMass())
  159. end
  160.  
  161. if parti==math.floor(parti) then
  162. par=part:Clone()
  163. table.insert(particles,par)
  164. par.Parent=beamm
  165. par.Transparency=1-s1.Volume
  166. par.light.Range=br*s1.Volume
  167. par.CFrame=cf(pos)*ang(math.random(-180,180),math.random(-180,180),math.random(-180,180))*cf(0,0,-10)
  168. end
  169.  
  170. mag=((wep.CFrame*cf(0,-1.5,0)).p-pos).magnitude
  171. ms.Scale=v3(s1.Volume,s1.Volume,mag)
  172. ms2.Scale=v3(ms.Scale.x/2,ms.Scale.y/2,mag-(.1/mag))
  173. beam.CFrame=cf((wep.CFrame*cf(0,-1.5,0)).p,pos)*cf(0,0,-mag/2)*ang(0,0,math.random(0,180))
  174. inner.CFrame=beam.CFrame
  175. pl.Range=br*s1.Volume
  176. pl2.Range=br*s1.Volume
  177. expl.Size=v3(math.random(9,13),math.random(9,13),math.random(9,13))*s1.Volume
  178. expl.Transparency=math.random(40,60)/100
  179. expl.CFrame=cf(pos)*ang(math.random(0,180),math.random(0,180),math.random(0,180))
  180. exa.Size=v3(4,4,4)*s1.Volume
  181. exa.CFrame=wep.CFrame*cf(0,-1.5,0)*ang(math.random(0,180),math.random(0,180),math.random(0,180))
  182. char.Torso.Velocity=char.Torso.Velocity-beam.CFrame.lookVector*(7*s1.Volume)
  183. end
  184. end)
Add Comment
Please, Sign In to add comment