Advertisement
samuelrichter66

gun

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