Advertisement
SomeRandomSkid

FE Laser gun?

Sep 19th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.17 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Please run as a server script. Use h/ instead of hl/.") end
  2. print("FE Compatibility: by WaverlyCole & Mokiros")
  3. InternalData = {}
  4. do
  5. script.Parent = owner.Character
  6. local Event = Instance.new("RemoteEvent")
  7. Event.Name = "UserInput"
  8. local function NewFakeEvent()
  9. local Fake = {fakeEvent=true,Connect=function(self,Func)self.Function=Func end}Fake.connect = Fake.Connect
  10. return Fake
  11. end
  12. local Mouse = {Target=nil,Hit=CFrame.new(),KeyUp=NewFakeEvent(),KeyDown=NewFakeEvent(),Button1Up=NewFakeEvent(),Button1Down=NewFakeEvent()}
  13. local UserInputService = {InputBegan=NewFakeEvent(),InputEnded=NewFakeEvent()}
  14. local ContextActionService = {Actions={},BindAction = function(self,actionName,Func,touch,...)
  15. self.Actions[actionName] = Func and {Name=actionName,Function=Func,Keys={...}} or nil
  16. end};ContextActionService.UnBindAction = ContextActionService.BindAction
  17. local function TriggerEvent(self,Event,...)
  18. local Trigger = Mouse[Event]
  19. if Trigger and Trigger.fakeEvent and Trigger.Function then
  20. Trigger.Function(...)
  21. end
  22. end
  23. Mouse.TrigEvent = TriggerEvent
  24. UserInputService.TrigEvent = TriggerEvent
  25. Event.OnServerEvent:Connect(function(FiredBy,Input)
  26. if FiredBy.Name ~= owner.Name then end
  27. if Input.MouseEvent then
  28. Mouse.Target = Input.Target
  29. Mouse.Hit = Input.Hit
  30. else
  31. local Begin = Input.UserInputState == Enum.UserInputState.Begin
  32. if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  33. return Mouse:TrigEvent(Begin and "Button1Down" or "Button1Up")
  34. end
  35. for _,Action in pairs(ContextActionService.Actions) do
  36. for _,Key in pairs(Action.Keys) do
  37. if Key==Input.KeyCode then
  38. Action.Function(Action.Name,Input.UserInputState,Input)
  39. end
  40. end
  41. end
  42. Mouse:TrigEvent(Begin and "KeyDown" or "KeyUp",Input.KeyCode.Name:lower())
  43. UserInputService:TrigEvent(Begin and "InputBegan" or "InputEnded",Input,false)
  44. end
  45. end)
  46. InternalData["Mouse"] = Mouse
  47. InternalData["ContextActionService"] = ContextActionService
  48. InternalData["UserInputService"] = UserInputService
  49. Event.Parent = NLS([[
  50. local Player = owner
  51. local Event = script:WaitForChild("UserInput")
  52. local UserInputService = game:GetService("UserInputService")
  53. local Mouse = Player:GetMouse()
  54. local Input = function(Input,gameProcessedEvent)
  55. if gameProcessedEvent then return end
  56. Event:FireServer({KeyCode=Input.KeyCode,UserInputType=Input.UserInputType,UserInputState=Input.UserInputState})
  57. end
  58. UserInputService.InputBegan:Connect(Input)
  59. UserInputService.InputEnded:Connect(Input)
  60. local Hit,Target
  61. while wait(1/30) do
  62. if Hit ~= Mouse.Hit or Target ~= Mouse.Target then
  63. Hit,Targer = Mouse.Hit,Mouse.Target
  64. Event:FireServer({["MouseEvent"]=true,["Target"]=Target,["Hit"]=Hit})
  65. end
  66. end
  67. ]],owner.Character)
  68. end
  69. RealGame = game;game = setmetatable({},{
  70. __index = function (self,Index)
  71. local Sandbox = function (Thing)
  72. if Thing:IsA("Player") then
  73. local RealPlayer = Thing
  74. return setmetatable({},{
  75. __index = function (self,Index)
  76. local Type = type(RealPlayer[Index])
  77. if Type == "function" then
  78. if Index:lower() == "getmouse" or Index:lower() == "mouse" then
  79. return function (self)
  80. return InternalData["Mouse"]
  81. end
  82. end
  83. return function (self,...)
  84. return RealPlayer[Index](RealPlayer,...)
  85. end
  86. else
  87. return RealPlayer[Index]
  88. end
  89. end;
  90. __tostring = function(self)
  91. return RealPlayer.Name
  92. end
  93. })
  94. end
  95. end
  96. if RealGame[Index] then
  97. local Type = type(RealGame[Index])
  98. if Type == "function" then
  99. if Index:lower() == "getservice" or Index:lower() == "service" then
  100. return function (self,Service)
  101. if Service:lower() == "players" then
  102. return setmetatable({},{
  103. __index = function (self2,Index2)
  104. local RealService = RealGame:GetService(Service)
  105. local Type2 = type(Index2)
  106. if Type2 == "function" then
  107. return function (self,...)
  108. return RealService[Index2](RealService,...)
  109. end
  110. else
  111. if Index2:lower() == "localplayer" then
  112. return Sandbox(owner)
  113. end
  114. return RealService[Index2]
  115. end
  116. end;
  117. __tostring = function(self)
  118. return RealGame:GetService(Service).Name
  119. end
  120. })
  121. elseif Service:lower() == "contextactionservice" then
  122. return InternalData["ContextActionService"]
  123. elseif Service:lower() == "contextactionservice" then
  124. return InternalData["UserInputService"]
  125. elseif Service:lower() == "runservice" then
  126. return setmetatable({},{
  127. __index = function(self2,Index2)
  128. local RealService = RealGame:GetService(Service)
  129. local Type2 = type(Index2)
  130. if Type2 == "function" then
  131. return function (self,...)
  132. return RealService[Index2](RealService,...)
  133. end
  134. else
  135. if Index2:lower() == "bindtorenderstep" then
  136. return function (self,Name,Priority,Function)
  137. return RealGame:GetService("RunService").Stepped:Connect(Function)
  138. end
  139. end
  140. if Index2:lower() == "renderstepped" then
  141. return RealService["Stepped"]
  142. end
  143. return RealService[Index2]
  144. end
  145. end
  146. })
  147. else
  148. return RealGame:GetService(Service)
  149. end
  150. end
  151. end
  152. return function (self,...)
  153. return RealGame[Index](RealGame,...)
  154. end
  155. else
  156. if game:GetService(Index) then
  157. return game:GetService(Index)
  158. end
  159. return RealGame[Index]
  160. end
  161. else
  162. return nil
  163. end
  164. end
  165. });Game = game;owner = game:GetService("Players").LocalPlayer;script = {}
  166. print("Complete! Running...")
  167.  
  168.  
  169. --//Paste script below this line.
  170.  
  171. ----------------------------------------
  172. -- Originally made by Alfederate :D --
  173. ----------------------------------------
  174.  
  175. -- there's no time to explain! --
  176.  
  177. local new=Instance.new
  178. local rad=math.rad
  179. local cf=CFrame.new
  180. local v3=Vector3.new
  181. local ang=function(x,y,z)
  182. return CFrame.Angles(rad(x),rad(y),rad(z))
  183. end
  184. local player=owner
  185. local char=player.Character
  186. local cam=workspace.Camera
  187. local mouse=player:GetMouse()
  188. local weld=function(a,b,c0,c1)
  189. m=Instance.new('Motor',a)
  190. m.Part0=a
  191. m.Part1=b
  192. m.C0=c0
  193. m.C1=c1
  194. return m
  195. end
  196.  
  197. snd='rbxassetid://306197164'
  198. beamm=Instance.new('Model',workspace)
  199. beamm.Name='beam'
  200.  
  201. laser=false
  202.  
  203. rs=Instance.new('Part',char)
  204. rs.Transparency=1
  205. rs.CanCollide=false
  206. rs.TopSurface,rs.BottomSurface=0,0
  207. rs.FormFactor=3
  208. rs.Size=Vector3.new(.5,.5,.5)
  209.  
  210. ls=rs:Clone()
  211. ls.Parent=char
  212.  
  213. rsw=weld(rs,char.Torso,cf(-1,-.5,0),cf())
  214. lsw=weld(ls,char.Torso,cf(1,-.5,0),cf())
  215. raw=weld(char['Right Arm'],rs,cf(-.5,.6,-.14),ang(90,0,-8))
  216. law=weld(char['Left Arm'],ls,cf(-.3,1.5,-.14),ang(90,0,43))
  217.  
  218. s1=Instance.new('Sound',char)
  219. s1.Volume=1
  220. s1.Pitch=1
  221. s1.Looped=true
  222. s1.SoundId=snd
  223.  
  224. particles={}
  225.  
  226. local wep=new('Part',char)
  227. wep.FormFactor=3
  228. wep.CanCollide=false
  229. wep.Size=v3(1,3,1)
  230. wep.TopSurface,wep.BottomSurface=0,0
  231. local wepw=weld(wep,char['Right Arm'],cf(.26,.4,.7),ang(0,0,8))
  232.  
  233. local beam=wep:Clone()
  234. beam:ClearAllChildren()
  235. beam.Material='Neon'
  236. beam.BrickColor=BrickColor.new('Toothpaste')
  237. beam.Size=Vector3.new(3,3,1)
  238. beam.Transparency=.5
  239. beam.Anchored=true
  240. local ms=Instance.new('BlockMesh',beam)
  241. local inner=beam:Clone()
  242. inner.Transparency=0
  243. inner.Material='SmoothPlastic'
  244. inner.BrickColor=BrickColor.new('Navy blue')
  245. local ms2=inner.Mesh
  246.  
  247. local expl=inner:Clone()
  248. expl.Mesh:Destroy()
  249. expl.Material='Neon'
  250. expl.BrickColor=BrickColor.new('Toothpaste')
  251. expl.Size=Vector3.new(11,11,11)
  252. expl.Transparency=.55
  253. pl=Instance.new('PointLight',expl)
  254. pl.Color=expl.BrickColor.Color
  255. pl.Range=pl.Range*2
  256. pl.Name='light'
  257. local br=pl.Range
  258.  
  259. local exa=expl:Clone()
  260. exa.Size=Vector3.new(4,4,4)
  261. pl2=exa.light
  262.  
  263. local part=exa:Clone()
  264. part.Size=Vector3.new(1.5,1.5,1.5)
  265. pl3=part.light
  266. pms=Instance.new('BlockMesh',part)
  267.  
  268. char.Humanoid.Died:connect(function()
  269. laser=false
  270. beam.Parent=nil
  271. inner.Parent=nil
  272. expl.Parent=nil
  273. exa.Parent=nil
  274. s1:stop()
  275. end)
  276.  
  277. mouse.Button1Down:connect(function() if char.Humanoid.Health~=0 then
  278. laser=true
  279. s1.Volume=1
  280. s1:play()
  281. end end)
  282. mouse.Button1Up:connect(function()
  283. laser=false
  284. beam.Parent=nil
  285. inner.Parent=nil
  286. expl.Parent=nil
  287. exa.Parent=nil
  288. s1:stop()
  289. end)
  290.  
  291. parti=0
  292. game:service'RunService'.Stepped:connect(function()
  293. parti=parti+1
  294. for i,v in pairs(particles) do
  295. v.CFrame=v.CFrame*CFrame.new(0,0,-.3)
  296. v.Transparency=v.Transparency+.08
  297. if v.Transparency >= 1 then
  298. v:Destroy()
  299. table.remove(particles,i)
  300. else
  301. v.Parent=beamm
  302. end
  303. end
  304. a=cam.CoordinateFrame.p
  305. b=mouse.Hit.p
  306. mhitr=Ray.new(a,(b-a).unit*999)
  307. mhit,ps=workspace:FindPartOnRayWithIgnoreList(mhitr,{char,beamm})
  308. raw.C1=ang(90+(mouse.Hit.lookVector.y*90),0,-8)
  309. law.C1=ang(90+(mouse.Hit.lookVector.y*90),0,43)
  310. if not char.Humanoid.Sit and not char.Humanoid.PlatformStand then
  311. char.Torso.CFrame=CFrame.new(char.Torso.CFrame.p,Vector3.new(ps.x,char.Torso.CFrame.p.y,ps.z))
  312. end
  313. if laser then
  314. beamm.Parent=workspace
  315. beam.Parent=beamm
  316. inner.Parent=beamm
  317. expl.Parent=beamm
  318. exa.Parent=beamm
  319. s1.Volume=s1.Volume-.002
  320.  
  321. 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)
  322. hit,pos=workspace:FindPartOnRayWithIgnoreList(ray,{char,beamm})
  323.  
  324. if hit and hit.Parent:findFirstChild('Humanoid') and s1.Volume > .3 and parti/8==math.floor(parti/8) then
  325. Instance.new('Explosion',workspace).Position=pos
  326. end
  327. if hit and hit.Parent==workspace.Terrain or hit==workspace.Terrain and parti/8==math.floor(parti/8) then
  328. e=Instance.new('Explosion',workspace)
  329. e.Position=pos
  330. e.BlastRadius=14
  331. e.BlastPressure=1e4
  332. end
  333. if hit and not hit.Anchored and not (hit:GetMass()>1e4) then
  334. hit.Velocity=hit.Velocity+beam.CFrame.lookVector*(1*s1.Volume*hit:GetMass())
  335. end
  336.  
  337. if parti==math.floor(parti) then
  338. par=part:Clone()
  339. table.insert(particles,par)
  340. par.Parent=beamm
  341. par.Transparency=1-s1.Volume
  342. par.light.Range=br*s1.Volume
  343. par.CFrame=cf(pos)*ang(math.random(-180,180),math.random(-180,180),math.random(-180,180))*cf(0,0,-10)
  344. end
  345.  
  346. mag=((wep.CFrame*cf(0,-1.5,0)).p-pos).magnitude
  347. ms.Scale=v3(s1.Volume,s1.Volume,mag)
  348. ms2.Scale=v3(ms.Scale.x/2,ms.Scale.y/2,mag-(.1/mag))
  349. beam.CFrame=cf((wep.CFrame*cf(0,-1.5,0)).p,pos)*cf(0,0,-mag/2)*ang(0,0,math.random(0,180))
  350. inner.CFrame=beam.CFrame
  351. pl.Range=br*s1.Volume
  352. pl2.Range=br*s1.Volume
  353. expl.Size=v3(math.random(9,13),math.random(9,13),math.random(9,13))*s1.Volume
  354. expl.Transparency=math.random(40,60)/100
  355. expl.CFrame=cf(pos)*ang(math.random(0,180),math.random(0,180),math.random(0,180))
  356. exa.Size=v3(4,4,4)*s1.Volume
  357. exa.CFrame=wep.CFrame*cf(0,-1.5,0)*ang(math.random(0,180),math.random(0,180),math.random(0,180))
  358. char.Torso.Velocity=char.Torso.Velocity-beam.CFrame.lookVector*(7*s1.Volume)
  359. end
  360. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement