Advertisement
gecksad

Untitled

Dec 25th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --]]
  2. --https://github.com/Mokiros/roblox-FE-compatibility
  3. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  4. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  5. local RealPlayer = Player
  6. do print("FE Compatibility code by Mokiros")local a=RealPlayer;script.Parent=a.Character;local b=Instance.new("RemoteEvent")b.Name="UserInput_Event"local function c()local d={_fakeEvent=true,Functions={},Connect=function(self,e)table.insert(self.Functions,e)end}d.connect=d.Connect;return d end;local f={Target=nil,Hit=CFrame.new(),KeyUp=c(),KeyDown=c(),Button1Up=c(),Button1Down=c(),Button2Up=c(),Button2Down=c()}local g={InputBegan=c(),InputEnded=c()}local CAS={Actions={},BindAction=function(self,h,i,j,...)CAS.Actions[h]=i and{Name=h,Function=i,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function k(self,l,...)local d=f[l]if d and d._fakeEvent then for m,e in pairs(d.Functions)do e(...)end end end;f.TrigEvent=k;g.TrigEvent=k;b.OnServerEvent:Connect(function(n,o)if n~=a then return end;f.Target=o.Target;f.Hit=o.Hit;if not o.isMouse then local p=o.UserInputState==Enum.UserInputState.Begin;if o.UserInputType==Enum.UserInputType.MouseButton1 then return f:TrigEvent(p and"Button1Down"or"Button1Up")end;if o.UserInputType==Enum.UserInputType.MouseButton2 then return f:TrigEvent(p and"Button2Down"or"Button2Up")end;for m,d in pairs(CAS.Actions)do for m,q in pairs(d.Keys)do if q==o.KeyCode then d.Function(d.Name,o.UserInputState,o)end end end;f:TrigEvent(p and"KeyDown"or"KeyUp",o.KeyCode.Name:lower())g:TrigEvent(p and"InputBegan"or"InputEnded",o,false)end end)b.Parent=NLS([==[local a=game:GetService("Players").LocalPlayer;local b=script:WaitForChild("UserInput_Event")local c=a:GetMouse()local d=game:GetService("UserInputService")local e=function(f,g)if g then return end;b:FireServer({KeyCode=f.KeyCode,UserInputType=f.UserInputType,UserInputState=f.UserInputState,Hit=c.Hit,Target=c.Target})end;d.InputBegan:Connect(e)d.InputEnded:Connect(e)local h,i;while wait(1/30)do if h~=c.Hit or i~=c.Target then h,i=c.Hit,c.Target;b:FireServer({isMouse=true,Target=i,Hit=h})end end]==],Player.Character)local r=game;local s={__index=function(self,q)local t=rawget(self,"_RealService")if t then return typeof(t[q])=="function"and function(m,...)return t[q](t,...)end or t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u end end}local function v(d,w)d._RealService=typeof(w)=="string"and r:GetService(w)or w;return setmetatable(d,s)end;local x={GetService=function(self,t)return rawget(self,t)or r:GetService(t)end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService"),RunService=v({_btrs={},RenderStepped=r:GetService("RunService").Heartbeat,BindToRenderStep=function(self,h,m,i)self._btrs[h]=self.Heartbeat:Connect(i)end,UnbindFromRenderStep=function(self,h)self._btrs[h]:Disconnect()end},"RunService")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;v(x,game)game,owner=x,x.Players.LocalPlayer end
  7.  
  8. local runDummyScript = function(f,scri)
  9. local oldenv = getfenv(f)
  10. local newenv = setmetatable({}, {
  11. __index = function(_, k)
  12. if k:lower() == 'script' then
  13. return scri
  14. else
  15. return oldenv[k]
  16. end
  17. end
  18. })
  19. setfenv(f, newenv)
  20. ypcall(function() f() end)
  21. end
  22. cors = {}
  23. mas = Instance.new("Model",game:GetService("Lighting"))
  24. mas.Name = "CompiledModel"
  25. o1 = Instance.new("Tool")
  26. o2 = Instance.new("Part")
  27. o3 = Instance.new("SpecialMesh")
  28. o4 = Instance.new("Sound")
  29. o5 = Instance.new("Sound")
  30. o6 = Instance.new("PointLight")
  31. o8 = Instance.new("LocalScript")
  32. o9 = Instance.new("Sound")
  33. o10 = Instance.new("LocalScript")
  34. o11 = Instance.new("Script")
  35. o1.Name = "LaserGun"
  36. o1.Parent = mas
  37. o1.TextureId = "http://www.roblox.com/asset?id=130093050"
  38. o1.GripPos = Vector3.new(0, -0.100000001, 0.75)
  39. o1.CanBeDropped = false
  40. o2.Name = "Handle"
  41. o2.Parent = o1
  42. o2.Position = Vector3.new(6.44000006, 0.670018971, 89.4400024)
  43. o2.Rotation = Vector3.new(-180, 0, -180)
  44. o2.CanCollide = false
  45. o2.FormFactor = Enum.FormFactor.Custom
  46. o2.Size = Vector3.new(0.580000222, 1.34000099, 2.48000145)
  47. o2.CFrame = CFrame.new(6.44000006, 0.670018971, 89.4400024, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  48. o2.BottomSurface = Enum.SurfaceType.Smooth
  49. o2.TopSurface = Enum.SurfaceType.Smooth
  50. o2.Position = Vector3.new(6.44000006, 0.670018971, 89.4400024)
  51. o3.Parent = o2
  52. o3.MeshId = "http://www.roblox.com/asset?id=130099641"
  53. o3.Scale = Vector3.new(0.649999976, 0.649999976, 0.649999976)
  54. o3.TextureId = "http://www.roblox.com/asset/?id=130267361"
  55. o3.MeshType = Enum.MeshType.FileMesh
  56. o4.Name = "Fire"
  57. o4.Parent = o2
  58. o4.Pitch = 1.2000000476837
  59. o4.SoundId = "http://www.roblox.com/asset?id=114488148"
  60. o4.Volume = 1
  61. o5.Name = "Reload"
  62. o5.Parent = o2
  63. o5.Pitch = 0.5
  64. o5.SoundId = "http://www.roblox.com/asset?id=94255248"
  65. o6.Parent = o2
  66. o6.Color = Color3.new(1, 0, 0)
  67. o6.Brightness = 4
  68. o6.Range = 6
  69. o8.Name = "ToolScript"
  70. o8.Parent = o1
  71. table.insert(cors,coroutine.create(function()
  72. wait()
  73. runDummyScript(function()
  74. -----------------
  75. --| Constants |--
  76. -----------------
  77.  
  78. local SHOT_SPEED = 100
  79. local SHOT_TIME = 1000
  80.  
  81. local NOZZLE_OFFSET = Vector3.new(0, 0.4, -1.1)
  82.  
  83. -----------------
  84. --| Variables |--
  85. -----------------
  86.  
  87. local PlayersService = Game:GetService('Players')
  88. local DebrisService = Game:GetService('Debris')
  89.  
  90. local Tool = script.Parent
  91. local Handle = Tool:WaitForChild('Handle')
  92.  
  93. local FireSound = Handle:WaitForChild('Fire')
  94. local ReloadSound = Handle:WaitForChild('Reload')
  95. local HitFadeSound = script:WaitForChild('HitFade')
  96.  
  97. local PointLight = Handle:WaitForChild('PointLight')
  98.  
  99. local Character = nil
  100. local Humanoid = nil
  101. local Player = nil
  102.  
  103. local BaseShot = nil
  104.  
  105. -----------------
  106. --| Functions |--
  107. -----------------
  108.  
  109. -- Returns a character ancestor and its Humanoid, or nil
  110. local function FindCharacterAncestor(subject)
  111. if subject and subject ~= Workspace then
  112. local humanoid = subject:FindFirstChild('Humanoid')
  113. if humanoid then
  114. return subject, humanoid
  115. else
  116. return FindCharacterAncestor(subject.Parent)
  117. end
  118. end
  119. return nil
  120. end
  121.  
  122. -- Removes any old creator tags and applies new ones to the specified target
  123. local function ApplyTags(target)
  124. while target:FindFirstChild('creator') do
  125. target.creator:Destroy()
  126. end
  127.  
  128. local creatorTag = Instance.new('ObjectValue')
  129. creatorTag.Value = Player
  130. creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
  131.  
  132. local iconTag = Instance.new('StringValue')
  133. iconTag.Value = Tool.TextureId
  134. iconTag.Name = 'icon'
  135.  
  136. iconTag.Parent = creatorTag
  137. creatorTag.Parent = target
  138. DebrisService:AddItem(creatorTag, 4)
  139. end
  140.  
  141. -- Returns all objects under instance with Transparency
  142. local function GetTransparentsRecursive(instance, partsTable)
  143. local partsTable = partsTable or {}
  144. for _, child in pairs(instance:GetChildren()) do
  145. if child:IsA('BasePart') or child:IsA('Decal') then
  146. table.insert(partsTable, child)
  147. end
  148. GetTransparentsRecursive(child, partsTable)
  149. end
  150. return partsTable
  151. end
  152.  
  153. local function SelectionBoxify(instance)
  154. local selectionBox = Instance.new('SelectionBox')
  155. selectionBox.Adornee = instance
  156. selectionBox.Color = BrickColor.new('Really red')
  157. selectionBox.Parent = instance
  158. return selectionBox
  159. end
  160.  
  161. local function Light(instance)
  162. local light = PointLight:Clone()
  163. light.Range = light.Range + 2
  164. light.Parent = instance
  165. end
  166.  
  167. local function FadeOutObjects(objectsWithTransparency, fadeIncrement)
  168. repeat
  169. local lastObject = nil
  170. for _, object in pairs(objectsWithTransparency) do
  171. object.Transparency = object.Transparency + fadeIncrement
  172. lastObject = object
  173. end
  174. wait()
  175. until lastObject.Transparency >= 1 or not lastObject
  176. end
  177.  
  178. local function Dematerialize(character, humanoid, firstPart)
  179. humanoid.WalkSpeed = 0
  180.  
  181. local parts = {}
  182. for _, child in pairs(character:GetChildren()) do
  183. if child:IsA('BasePart') then
  184. child.Anchored = true
  185. table.insert(parts, child)
  186. elseif child:IsA('LocalScript') or child:IsA('Script') then
  187. child:Destroy()
  188. end
  189. end
  190.  
  191. local selectionBoxes = {}
  192.  
  193. local firstSelectionBox = SelectionBoxify(firstPart)
  194. Light(firstPart)
  195. wait(0.05)
  196.  
  197. for _, part in pairs(parts) do
  198. if part ~= firstPart then
  199. table.insert(selectionBoxes, SelectionBoxify(part))
  200. Light(part)
  201. end
  202. end
  203.  
  204. local objectsWithTransparency = GetTransparentsRecursive(character)
  205. FadeOutObjects(objectsWithTransparency, 0.1)
  206.  
  207. wait(0.5)
  208.  
  209. humanoid.Health = 0
  210. DebrisService:AddItem(character, 2)
  211.  
  212. local fadeIncrement = 0.05
  213. Delay(0.2, function()
  214. FadeOutObjects({firstSelectionBox}, fadeIncrement)
  215. if character then
  216. character:Destroy()
  217. end
  218. end)
  219. FadeOutObjects(selectionBoxes, fadeIncrement)
  220. end
  221.  
  222. local function OnTouched(shot, otherPart)
  223. local character, humanoid = FindCharacterAncestor(otherPart)
  224. if character and humanoid and character ~= Character then
  225. ApplyTags(humanoid)
  226. if shot then
  227. local hitFadeSound = shot:FindFirstChild(HitFadeSound.Name)
  228. if hitFadeSound then
  229. hitFadeSound.Parent = humanoid.Torso
  230. hitFadeSound:Play()
  231. end
  232. shot:Destroy()
  233. end
  234. Dematerialize(character, humanoid, otherPart)
  235. end
  236. end
  237.  
  238. local function OnEquipped()
  239. Character = Tool.Parent
  240. Humanoid = Character:WaitForChild('Humanoid')
  241. Player = PlayersService:GetPlayerFromCharacter(Character)
  242. end
  243.  
  244. local function OnActivated()
  245. if Tool.Enabled and Humanoid.Health > 0 then
  246. Tool.Enabled = false
  247.  
  248. FireSound:Play()
  249.  
  250. local handleCFrame = Handle.CFrame
  251. local firingPoint = handleCFrame.p + handleCFrame:vectorToWorldSpace(NOZZLE_OFFSET)
  252. local shotCFrame = CFrame.new(firingPoint, Humanoid.TargetPoint)
  253.  
  254. local laserShotClone = BaseShot:Clone()
  255. laserShotClone.CFrame = shotCFrame + (shotCFrame.lookVector * (BaseShot.Size.Z / 2))
  256. local bodyVelocity = Instance.new('BodyVelocity')
  257. bodyVelocity.velocity = shotCFrame.lookVector * SHOT_SPEED
  258. bodyVelocity.Parent = laserShotClone
  259. laserShotClone.Touched:connect(function(otherPart)
  260. OnTouched(laserShotClone, otherPart)
  261. end)
  262. DebrisService:AddItem(laserShotClone, SHOT_TIME)
  263. laserShotClone.Parent = Tool
  264.  
  265. wait(0) -- FireSound length
  266.  
  267. ReloadSound:Play()
  268. wait(0) -- ReloadSound length
  269.  
  270. Tool.Enabled = true
  271. end
  272. end
  273.  
  274. local function OnUnequipped()
  275.  
  276. end
  277.  
  278. --------------------
  279. --| Script Logic |--
  280. --------------------
  281.  
  282. BaseShot = Instance.new('Part')
  283. BaseShot.Name = 'Effect'
  284. BaseShot.FormFactor = Enum.FormFactor.Custom
  285. BaseShot.Size = Vector3.new(0.2, 0.2, 3)
  286. BaseShot.CanCollide = false
  287. BaseShot.BrickColor = BrickColor.new('Really red')
  288. SelectionBoxify(BaseShot)
  289. Light(BaseShot)
  290. HitFadeSound:Clone().Parent = BaseShot
  291.  
  292. Tool.Equipped:connect(OnEquipped)
  293. Tool.Unequipped:connect(OnUnequipped)
  294. Tool.Activated:connect(OnActivated)
  295. end,o8)
  296. end))
  297. o9.Name = "HitFade"
  298. o9.Parent = o8
  299. o9.SoundId = "http://www.roblox.com/asset?id=130113415"
  300. o10.Name = "MouseIcon"
  301. o10.Parent = o1
  302. table.insert(cors,coroutine.create(function()
  303. wait()
  304. runDummyScript(function()
  305. local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
  306. local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'
  307.  
  308. local Tool = script.Parent
  309.  
  310. local Mouse = nil
  311.  
  312. local function UpdateIcon()
  313. if Mouse then
  314. Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
  315. end
  316. end
  317.  
  318. local function OnEquipped(mouse)
  319. Mouse = mouse
  320. UpdateIcon()
  321. end
  322.  
  323. local function OnChanged(property)
  324. if property == 'Enabled' then
  325. UpdateIcon()
  326. end
  327. end
  328.  
  329. Tool.Equipped:connect(OnEquipped)
  330. Tool.Changed:connect(OnChanged)
  331.  
  332. end,o10)
  333. end))
  334. o11.Name = "Shu_hold"
  335. o11.Parent = o1
  336. table.insert(cors,coroutine.create(function()
  337. wait()
  338. runDummyScript(function()
  339. --This script gives you a next-gen hold script better than the current one. You actually hold the barrel parallel to your face. Put it in any gun you want. Original script by Xliver101, Converted to universal script by ToastyToaster.
  340.  
  341. selected = false
  342. RSH, LSH = nil, nil
  343. GRP = nil
  344. RW, LW = Instance.new("Weld"), Instance.new("Weld")
  345. anim = "none"
  346. function WaitForChild(obj, ch_n)
  347. local t = time()
  348. while not obj:FindFirstChild(ch_n) and time() - t < 10 do wait(0.1) end
  349. return obj:FindFirstChild(ch_n)
  350. end
  351. script.Parent.Equipped:connect(function()
  352. if selected then return end
  353. selected = true
  354. player = game.Players:playerFromCharacter(script.Parent.Parent)
  355. local ch = script.Parent.Parent
  356. WaitForChild(ch, "Torso")
  357. RSH = WaitForChild(ch.Torso, "Right Shoulder")
  358. LSH = WaitForChild(ch.Torso, "Left Shoulder")
  359. GRP = WaitForChild(ch["Right Arm"], "RightGrip")
  360. _G.Grip = GRP
  361. --
  362. RSH.Part1 = nil
  363. LSH.Part1 = nil
  364. --
  365. RW.Part0 = ch.Torso
  366. RW.C0 = CFrame.new(1.5, 0.5, 0) --* CFrame.fromEulerAnglesXYZ(1.3, 0, -0.5)
  367. RW.C1 = CFrame.new(0, 0.5, 0)
  368. RW.Part1 = ch["Right Arm"]
  369. RW.Parent = ch.Torso
  370. _G.R = RW
  371. --
  372. LW.Part0 = ch.Torso
  373. LW.C0 = CFrame.new(-1.5, 0.5, 0) --* CFrame.fromEulerAnglesXYZ(1.7, 0, 0.8)
  374. LW.C1 = CFrame.new(0, 0.5, 0)
  375. LW.Part1 = ch["Left Arm"]
  376. LW.Parent = ch.Torso
  377. _G.L = LW
  378. --
  379. GRP.C0 = CFrame.new(0, -1, -0.5) * CFrame.fromEulerAnglesXYZ(-1.22, -0.45, 0.22)
  380. for i = 0, 1, 0.05 do
  381. wait()
  382. RW.C0 = CFrame.new(1.5, 0.5, 0.25) * CFrame.fromEulerAnglesXYZ(1.3*i, 0, -0.5*i)
  383. LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7*i, 0, 0.8*i)
  384. LW.C1 = CFrame.new(0.3*i, 1+1*i, 0)
  385. end
  386. wait()
  387. local rg = (ch["Right Arm"]:FindFirstChild("RightGrip") or GRP)
  388. if rg ~= GRP then
  389. GRP.Parent = ch["Right Arm"]
  390. rg:remove()
  391. end
  392. end)
  393. script.Parent.Unequipped:connect(function()
  394. selected = false
  395. local pl = player
  396. RW.C0 = CFrame.new(0,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
  397. LW.C0 = CFrame.new(0,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
  398. LW.C1 = CFrame.new(0,0,0)
  399. RW.Parent = nil
  400. LW.Parent = nil
  401. RSH.Part1 = pl.Character["Right Arm"]
  402. LSH.Part1 = pl.Character["Left Arm"]
  403. end)
  404. function armReload()
  405. for i = 0, 1, 0.1 do
  406. wait()
  407. LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.3*i, 0, 0.9*i)
  408. LW.C1 = CFrame.new(0.3*i, 1+1*i, 0)
  409. end
  410. end
  411. function gunOut()
  412. for i = 0, 0.3, 0.06 do
  413. wait()
  414. GRP.C0 = CFrame.new(0+i, -1-i, 0+(2*i)) * CFrame.fromEulerAnglesXYZ(-2.22, -0.45, 0.42)
  415. LW.C0 = CFrame.new(-1, 0.5, 0) * CFrame.fromEulerAnglesXYZ(4.2, 0, 2.9)
  416. LW.C1 = CFrame.new(0.8*i, 1.1+i, -0.3)
  417. end
  418. end
  419. function gunReturn()
  420. RW.C0 = CFrame.new(1.5, 0.5, 0.25) * CFrame.fromEulerAnglesXYZ(1.3, 0, -0.5)
  421. LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7, 0, 0.8)
  422. LW.C1 = CFrame.new(0.3, 1+1, 0)
  423. GRP.C0 = CFrame.new(0, -1, -0.5) * CFrame.fromEulerAnglesXYZ(-1.22, -0.45, 0.22)
  424. end
  425. end,o11)
  426. end))
  427. mas.Parent = workspace
  428. mas:MakeJoints()
  429. local mas1 = mas:GetChildren()
  430. for i=1,#mas1 do
  431. mas1[i].Parent = game:GetService("Players").LocalPlayer.Backpack
  432. ypcall(function() mas1[i]:MakeJoints() end)
  433. end
  434. mas:Destroy()
  435. for i=1,#cors do
  436. coroutine.resume(cors[i])
  437. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement