Advertisement
Axprotss

Testing BlueGun Script

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