Advertisement
evan97401

[ROBLOX] Blast gun Script !

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