Advertisement
SCR1PT_ED1T0R

FE Laser Gun

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