hecknes

Laser4

Jun 2nd, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.39 KB | None | 0 0
  1.  
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  4. do
  5. print("FE Compatibility code by Mokiros")
  6. script.Parent = Player.Character
  7.  
  8. --RemoteEvent for communicating
  9. local Event = Instance.new("RemoteEvent")
  10. Event.Name = "UserInput_Event"
  11.  
  12. --Fake event to make stuff like Mouse.KeyDown work
  13. local function fakeEvent()
  14. local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  15. t.connect = t.Connect
  16. return t
  17. end
  18.  
  19. --Creating fake input objects with fake variables
  20. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  21. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  22. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  23. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  24. end}
  25. --Merged 2 functions into one by checking amount of arguments
  26. CAS.UnbindAction = CAS.BindAction
  27.  
  28. --This function will trigger the events that have been :Connect()'ed
  29. local function te(self,ev,...)
  30. local t = m[ev]
  31. if t and t._fakeEvent and t.Function then
  32. t.Function(...)
  33. end
  34. end
  35. m.TrigEvent = te
  36. UIS.TrigEvent = te
  37.  
  38. Event.OnServerEvent:Connect(function(plr,io)
  39. if plr~=Player then return end
  40. if io.isMouse then
  41. m.Target = io.Target
  42. m.Hit = io.Hit
  43. else
  44. local b = io.UserInputState == Enum.UserInputState.Begin
  45. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  46. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  47. end
  48. for _,t in pairs(CAS.Actions) do
  49. for _,k in pairs(t.Keys) do
  50. if k==io.KeyCode then
  51. t.Function(t.Name,io.UserInputState,io)
  52. end
  53. end
  54. end
  55. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  56. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  57. end
  58. end)
  59. Event.Parent = NLS([==[
  60.  
  61. local Event = script:WaitForChild("UserInput_Event")
  62.  
  63. local UIS = game:GetService("UserInputService")
  64. local input = function(io,a)
  65. if a then return end
  66. --Since InputObject is a client-side instance, we create and pass table instead
  67. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  68. end
  69. UIS.InputBegan:Connect(input)
  70. UIS.InputEnded:Connect(input)
  71.  
  72. local h,t
  73. --Give the
  74.  
  75.  
  76. ----------------------------------------
  77. -- Originally made by Alfederate :D --
  78. ----------------------------------------
  79.  
  80. -- there's no time to explain! --
  81.  
  82. local new=Instance.new
  83. local rad=math.rad
  84. local cf=CFrame.new
  85. local v3=Vector3.new
  86. local ang=function(x,y,z)
  87. return CFrame.Angles(rad(x),rad(y),rad(z))
  88. end
  89. local char=player.Character
  90. local cam=workspace.Camera
  91. local weld=function(a,b,c0,c1)
  92. m=Instance.new('Motor',a)
  93. m.Part0=a
  94. m.Part1=b
  95. m.C0=c0
  96. m.C1=c1
  97. return m
  98. end
  99.  
  100. snd='rbxassetid://348756576'
  101. beamm=Instance.new('Model',workspace)
  102. beamm.Name='beam'
  103.  
  104. laser=false
  105.  
  106. rs=Instance.new('Part',char)
  107. rs.Transparency=1
  108. rs.CanCollide=false
  109. rs.TopSurface,rs.BottomSurface=0,0
  110. rs.FormFactor=3
  111. rs.Size=Vector3.new(.5,.5,.5)
  112.  
  113. ls=rs:Clone()
  114. ls.Parent=char
  115.  
  116. rsw=weld(rs,char.Torso,cf(-1,-.5,0),cf())
  117. lsw=weld(ls,char.Torso,cf(1,-.5,0),cf())
  118. raw=weld(char['Right Arm'],rs,cf(-.5,.6,-.14),ang(90,0,-8))
  119. law=weld(char['Left Arm'],ls,cf(-.3,1.5,-.14),ang(90,0,43))
  120.  
  121. s1=Instance.new('Sound',char)
  122. s1.Volume=1
  123. s1.Pitch=1
  124. s1.Looped=true
  125. s1.SoundId=snd
  126.  
  127. particles={}
  128.  
  129. local wep=new('Part',char)
  130. wep.FormFactor=3
  131. wep.CanCollide=false
  132. wep.Size=v3(1,3,1)
  133. wep.TopSurface,wep.BottomSurface=0,0
  134. local wepw=weld(wep,char['Right Arm'],cf(.26,.4,.7),ang(0,0,8))
  135.  
  136. local beam=wep:Clone()
  137. beam:ClearAllChildren()
  138. beam.Material='Neon'
  139. beam.BrickColor=BrickColor.new('Toothpaste')
  140. beam.Size=Vector3.new(3,3,1)
  141. beam.Transparency=.5
  142. beam.Anchored=true
  143. local ms=Instance.new('BlockMesh',beam)
  144. local inner=beam:Clone()
  145. inner.Transparency=0
  146. inner.Material='SmoothPlastic'
  147. inner.BrickColor=BrickColor.new('Navy blue')
  148. local ms2=inner.Mesh
  149.  
  150. local expl=inner:Clone()
  151. expl.Mesh:Destroy()
  152. expl.Material='Neon'
  153. expl.BrickColor=BrickColor.new('Toothpaste')
  154. expl.Size=Vector3.new(11,11,11)
  155. expl.Transparency=.55
  156. pl=Instance.new('PointLight',expl)
  157. pl.Color=expl.BrickColor.Color
  158. pl.Range=pl.Range*2
  159. pl.Name='light'
  160. local br=pl.Range
  161.  
  162. local exa=expl:Clone()
  163. exa.Size=Vector3.new(4,4,4)
  164. pl2=exa.light
  165.  
  166. local part=exa:Clone()
  167. part.Size=Vector3.new(1.5,1.5,1.5)
  168. pl3=part.light
  169. pms=Instance.new('BlockMesh',part)
  170.  
  171. char.Humanoid.Died:connect(function()
  172. laser=false
  173. beam.Parent=nil
  174. inner.Parent=nil
  175. expl.Parent=nil
  176. exa.Parent=nil
  177. s1:stop()
  178. end)
  179.  
  180. mouse.Button1Down:connect(function() if char.Humanoid.Health~=0 then
  181. laser=true
  182. s1.Volume=1
  183. s1:play()
  184. end end)
  185. mouse.Button1Up:connect(function()
  186. laser=false
  187. beam.Parent=nil
  188. inner.Parent=nil
  189. expl.Parent=nil
  190. exa.Parent=nil
  191. s1:stop()
  192. end)
  193.  
  194. parti=0
  195. game:service'RunService'.Stepped:connect(function()
  196. parti=parti+1
  197. for i,v in pairs(particles) do
  198. v.CFrame=v.CFrame*CFrame.new(0,0,-.3)
  199. v.Transparency=v.Transparency+.08
  200. if v.Transparency >= 1 then
  201. v:Destroy()
  202. table.remove(particles,i)
  203. else
  204. v.Parent=beamm
  205. end
  206. end
  207. a=cam.CoordinateFrame.p
  208. b=mouse.Hit.p
  209. mhitr=Ray.new(a,(b-a).unit*999)
  210. mhit,ps=workspace:FindPartOnRayWithIgnoreList(mhitr,{char,beamm})
  211. raw.C1=ang(90+(mouse.Hit.lookVector.y*90),0,-8)
  212. law.C1=ang(90+(mouse.Hit.lookVector.y*90),0,43)
  213. if not char.Humanoid.Sit and not char.Humanoid.PlatformStand then
  214. char.Torso.CFrame=CFrame.new(char.Torso.CFrame.p,Vector3.new(ps.x,char.Torso.CFrame.p.y,ps.z))
  215. end
  216. if laser then
  217. beamm.Parent=workspace
  218. beam.Parent=beamm
  219. inner.Parent=beamm
  220. expl.Parent=beamm
  221. exa.Parent=beamm
  222. s1.Volume=s1.Volume-.002
  223.  
  224. 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)
  225. hit,pos=workspace:FindPartOnRayWithIgnoreList(ray,{char,beamm})
  226.  
  227. if hit and hit.Parent:findFirstChild('Humanoid') and s1.Volume > .3 and parti/8==math.floor(parti/8) then
  228. Instance.new('Explosion',workspace).Position=pos
  229. end
  230. if hit and hit.Parent==workspace.Terrain or hit==workspace.Terrain and parti/8==math.floor(parti/8) then
  231. e=Instance.new('Explosion',workspace)
  232. e.Position=pos
  233. e.BlastRadius=14
  234. e.BlastPressure=1e4
  235. end
  236. if hit and not hit.Anchored and not (hit:GetMass()>1e4) then
  237. hit.Velocity=hit.Velocity+beam.CFrame.lookVector*(1*s1.Volume*hit:GetMass())
  238. end
  239.  
  240. if parti==math.floor(parti) then
  241. par=part:Clone()
  242. table.insert(particles,par)
  243. par.Parent=beamm
  244. par.Transparency=1-s1.Volume
  245. par.light.Range=br*s1.Volume
  246. par.CFrame=cf(pos)*ang(math.random(-180,180),math.random(-180,180),math.random(-180,180))*cf(0,0,-10)
  247. end
  248.  
  249. mag=((wep.CFrame*cf(0,-1.5,0)).p-pos).magnitude
  250. ms.Scale=v3(s1.Volume,s1.Volume,mag)
  251. ms2.Scale=v3(ms.Scale.x/2,ms.Scale.y/2,mag-(.1/mag))
  252. beam.CFrame=cf((wep.CFrame*cf(0,-1.5,0)).p,pos)*cf(0,0,-mag/2)*ang(0,0,math.random(0,180))
  253. inner.CFrame=beam.CFrame
  254. pl.Range=br*s1.Volume
  255. pl2.Range=br*s1.Volume
  256. expl.Size=v3(math.random(9,13),math.random(9,13),math.random(9,13))*s1.Volume
  257. expl.Transparency=math.random(40,60)/100
  258. expl.CFrame=cf(pos)*ang(math.random(0,180),math.random(0,180),math.random(0,180))
  259. exa.Size=v3(4,4,4)*s1.Volume
  260. exa.CFrame=wep.CFrame*cf(0,-1.5,0)*ang(math.random(0,180),math.random(0,180),math.random(0,180))
  261. char.Torso.Velocity=char.Torso.Velocity-beam.CFrame.lookVector*(7*s1.Volume)
  262. end
  263. end)
Advertisement
Add Comment
Please, Sign In to add comment