DarkScriptZEditors

Untitled

Feb 1st, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.14 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 V2 by Mokiros")
  6. local RealPlayer = RealPlayer
  7. script.Parent = RealPlayer.Character
  8.  
  9. --Fake event to make stuff like Mouse.KeyDown work
  10. local Disconnect_Function = function(this)
  11. this[1].Functions[this[2]] = nil
  12. end
  13. local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
  14. local FakeEvent_Metatable = {__index={
  15. Connect = function(this,f)
  16. local i = tostring(math.random(0,10000))
  17. while this.Functions[i] do
  18. i = tostring(math.random(0,10000))
  19. end
  20. this.Functions[i] = f
  21. return setmetatable({this,i},Disconnect_Metatable)
  22. end
  23. }}
  24. FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
  25. local function fakeEvent()
  26. return setmetatable({Functions={}},FakeEvent_Metatable)
  27. end
  28.  
  29. --Creating fake input objects with fake variables
  30. local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  31. FakeMouse.keyUp = FakeMouse.KeyUp
  32. FakeMouse.keyDown = FakeMouse.KeyDown
  33. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  34. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  35. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  36. end}
  37. --Merged 2 functions into one by checking amount of arguments
  38. CAS.UnbindAction = CAS.BindAction
  39.  
  40. --This function will trigger the events that have been :Connect()'ed
  41. local function TriggerEvent(self,ev,...)
  42. for _,f in pairs(self[ev].Functions) do
  43. f(...)
  44. end
  45. end
  46. FakeMouse.TriggerEvent = TriggerEvent
  47. UIS.TriggerEvent = TriggerEvent
  48.  
  49. --Client communication
  50. local Event = Instance.new("RemoteEvent")
  51. Event.Name = "UserInput_Event"
  52. Event.OnServerEvent:Connect(function(plr,io)
  53. if plr~=RealPlayer then return end
  54. FakeMouse.Target = io.Target
  55. FakeMouse.Hit = io.Hit
  56. if not io.isMouse then
  57. local b = io.UserInputState == Enum.UserInputState.Begin
  58. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  59. return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
  60. end
  61. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  62. return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
  63. end
  64. for _,t in pairs(CAS.Actions) do
  65. for _,k in pairs(t.Keys) do
  66. if k==io.KeyCode then
  67. t.Function(t.Name,io.UserInputState,io)
  68. end
  69. end
  70. end
  71. FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  72. UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
  73. end
  74. end)
  75. Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
  76. local Mouse = owner:GetMouse()
  77. local UIS = game:GetService("UserInputService")
  78. local input = function(io,RobloxHandled)
  79. if RobloxHandled then return end
  80. --Since InputObject is a client-side instance, we create and pass table instead
  81. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  82. end
  83. UIS.InputBegan:Connect(input)
  84. UIS.InputEnded:Connect(input)
  85. local h,t
  86. --Give the server mouse data every second frame, but only if the values changed
  87. --If player is not moving their mouse, client won't fire events
  88. local HB = game:GetService("RunService").Heartbeat
  89. while true do
  90. if h~=Mouse.Hit or t~=Mouse.Target then
  91. h,t=Mouse.Hit,Mouse.Target
  92. Event:FireServer({isMouse=true,Target=t,Hit=h})
  93. end
  94. --Wait 2 frames
  95. for i=1,2 do
  96. HB:Wait()
  97. end
  98. end]==],script)
  99.  
  100. ----Sandboxed game object that allows the usage of client-side methods and services
  101. --Real game object
  102. local RealGame = game
  103.  
  104. --Metatable for fake service
  105. local FakeService_Metatable = {
  106. __index = function(self,k)
  107. local s = rawget(self,"_RealService")
  108. if s then
  109. return typeof(s[k])=="function"
  110. and function(_,...)return s[k](s,...)end or s[k]
  111. end
  112. end,
  113. __newindex = function(self,k,v)
  114. local s = rawget(self,"_RealService")
  115. if s then s[k]=v end
  116. end
  117. }
  118. local function FakeService(t,RealService)
  119. t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
  120. return setmetatable(t,FakeService_Metatable)
  121. end
  122.  
  123. --Fake game object
  124. local FakeGame = {
  125. GetService = function(self,s)
  126. return rawget(self,s) or RealGame:GetService(s)
  127. end,
  128. Players = FakeService({
  129. LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
  130. },"Players"),
  131. UserInputService = FakeService(UIS,"UserInputService"),
  132. ContextActionService = FakeService(CAS,"ContextActionService"),
  133. RunService = FakeService({
  134. _btrs = {},
  135. RenderStepped = RealGame:GetService("RunService").Heartbeat,
  136. BindToRenderStep = function(self,name,_,fun)
  137. self._btrs[name] = self.Heartbeat:Connect(fun)
  138. end,
  139. UnbindFromRenderStep = function(self,name)
  140. self._btrs[name]:Disconnect()
  141. end,
  142. },"RunService")
  143. }
  144. rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
  145. FakeGame.service = FakeGame.GetService
  146. FakeService(FakeGame,game)
  147. --Changing owner to fake player object to support owner:GetMouse()
  148. game,owner = FakeGame,FakeGame.Players.LocalPlayer
  149. end
  150. --Converted with ttyyuu12345's model to script plugin v4
  151. function sandbox(var,func)
  152. local env = getfenv(func)
  153. local newenv = setmetatable({},{
  154. __index = function(self,k)
  155. if k=="script" then
  156. return var
  157. else
  158. return env[k]
  159. end
  160. end,
  161. })
  162. setfenv(func,newenv)
  163. return func
  164. end
  165. cors = {}
  166. mas = Instance.new("Model",game:GetService("Lighting"))
  167. Tool0 = Instance.new("Tool")
  168. Part1 = Instance.new("Part")
  169. SpecialMesh2 = Instance.new("SpecialMesh")
  170. Sound3 = Instance.new("Sound")
  171. Sound4 = Instance.new("Sound")
  172. PointLight5 = Instance.new("PointLight")
  173. Sound6 = Instance.new("Sound")
  174. LocalScript7 = Instance.new("LocalScript")
  175. LocalScript8 = Instance.new("LocalScript")
  176. Script9 = Instance.new("Script")
  177. Tool0.Name = "HyperlaserGun"
  178. Tool0.Parent = mas
  179. Tool0.TextureId = "http://www.roblox.com/asset/?id=130093050"
  180. Tool0.GripPos = Vector3.new(0, -0.100000001, 0.75)
  181. Tool0.CanBeDropped = false
  182. Part1.Name = "Handle"
  183. Part1.Parent = Tool0
  184. Part1.Rotation = Vector3.new(153.539993, -9.7699995, -163.440002)
  185. Part1.FormFactor = Enum.FormFactor.Custom
  186. Part1.Size = Vector3.new(0.580000222, 1.34000099, 2.48000145)
  187. Part1.CFrame = CFrame.new(0.0399999991, 0, 0.0700000003, -0.944598317, 0.280954868, -0.169695258, 0.327697694, 0.836576641, -0.439038545, 0.0186130833, -0.470323801, -0.88229686)
  188. Part1.BottomSurface = Enum.SurfaceType.Smooth
  189. Part1.TopSurface = Enum.SurfaceType.Smooth
  190. Part1.Position = Vector3.new(0.0399999991, 0, 0.0700000003)
  191. Part1.Orientation = Vector3.new(26.039999, -169.110001, 21.3899994)
  192. SpecialMesh2.Parent = Part1
  193. SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=130099641"
  194. SpecialMesh2.Scale = Vector3.new(0.649999976, 0.649999976, 0.649999976)
  195. SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=130093033"
  196. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  197. SpecialMesh2.Scale = Vector3.new(0.649999976, 0.649999976, 0.649999976)
  198. Sound3.Name = "Fire"
  199. Sound3.Parent = Part1
  200. Sound3.SoundId = "http://www.roblox.com/asset?id=130113322"
  201. Sound4.Name = "Reload"
  202. Sound4.Parent = Part1
  203. Sound4.SoundId = "http://www.roblox.com/asset?id=130113370"
  204. PointLight5.Parent = Part1
  205. PointLight5.Color = Color3.new(0, 1, 1)
  206. PointLight5.Range = 6
  207. PointLight5.Color = Color3.new(0, 1, 1)
  208. Sound6.Name = "HitFade"
  209. Sound6.Parent = Part1
  210. Sound6.SoundId = "http://www.roblox.com/asset?id=130113415"
  211. LocalScript7.Name = "ToolScript"
  212. LocalScript7.Parent = Tool0
  213. table.insert(cors,sandbox(LocalScript7,function()
  214. --Rescripted by Luckymaxer
  215.  
  216. Tool = script.Parent
  217. Handle = Tool:WaitForChild("Handle")
  218.  
  219. Players = game:GetService("Players")
  220.  
  221. ServerControl = Tool:WaitForChild("ServerControl")
  222. ClientControl = Tool:WaitForChild("ClientControl")
  223.  
  224. ClientControl.OnClientInvoke = (function(Mode, Value)
  225. if Mode == "PlaySound" and Value then
  226. Value:Play()
  227. end
  228. end)
  229.  
  230. function InvokeServer(Mode, Value, arg)
  231. pcall(function()
  232. ServerControl:InvokeServer(Mode, Value, arg)
  233. end)
  234. end
  235.  
  236. function Equipped(Mouse)
  237. Character = Tool.Parent
  238. Player = Players:GetPlayerFromCharacter(Character)
  239. Humanoid = Character:FindFirstChild("Humanoid")
  240. if not Player or not Humanoid or Humanoid.Health == 0 then
  241. return
  242. end
  243. Mouse.Button1Down:connect(function()
  244. InvokeServer("Click", true, Mouse.Hit.p)
  245. end)
  246. end
  247.  
  248. local function Unequipped()
  249.  
  250. end
  251.  
  252. Tool.Equipped:connect(Equipped)
  253. Tool.Unequipped:connect(Unequipped)
  254. end))
  255. LocalScript8.Name = "MouseIcon"
  256. LocalScript8.Parent = Tool0
  257. table.insert(cors,sandbox(LocalScript8,function()
  258. local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
  259. local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'
  260.  
  261. local Tool = script.Parent
  262.  
  263. local Mouse = nil
  264.  
  265. local function UpdateIcon()
  266. if Mouse then
  267. Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
  268. end
  269. end
  270.  
  271. local function OnEquipped(mouse)
  272. Mouse = mouse
  273. UpdateIcon()
  274. end
  275.  
  276. local function OnChanged(property)
  277. if property == 'Enabled' then
  278. UpdateIcon()
  279. end
  280. end
  281.  
  282. Tool.Equipped:connect(OnEquipped)
  283. Tool.Changed:connect(OnChanged)
  284.  
  285. end))
  286. Script9.Parent = Tool0
  287. table.insert(cors,sandbox(Script9,function()
  288. --Rescripted by Luckymaxer
  289.  
  290. Tool = script.Parent
  291. Handle = Tool:WaitForChild("Handle")
  292.  
  293. Players = game:GetService("Players")
  294. Debris = game:GetService("Debris")
  295.  
  296. Speed = 100
  297. Duration = 1
  298.  
  299. NozzleOffset = Vector3.new(0, 0.4, -1.1)
  300.  
  301. Sounds = {
  302. Fire = Handle:WaitForChild("Fire"),
  303. Reload = Handle:WaitForChild("Reload"),
  304. HitFade = Handle:WaitForChild("HitFade")
  305. }
  306.  
  307. PointLight = Handle:WaitForChild("PointLight")
  308.  
  309. ServerControl = (Tool:FindFirstChild("ServerControl") or Instance.new("RemoteFunction"))
  310. ServerControl.Name = "ServerControl"
  311. ServerControl.Parent = Tool
  312.  
  313. ClientControl = (Tool:FindFirstChild("ClientControl") or Instance.new("RemoteFunction"))
  314. ClientControl.Name = "ClientControl"
  315. ClientControl.Parent = Tool
  316.  
  317. ServerControl.OnServerInvoke = (function(player, Mode, Value, arg)
  318. if player ~= Player or Humanoid.Health == 0 or not Tool.Enabled then
  319. return
  320. end
  321. if Mode == "Click" and Value then
  322. Activated(arg)
  323. end
  324. end)
  325.  
  326. function InvokeClient(Mode, Value)
  327. pcall(function()
  328. ClientControl:InvokeClient(Player, Mode, Value)
  329. end)
  330. end
  331.  
  332. function TagHumanoid(humanoid, player)
  333. local Creator_Tag = Instance.new("ObjectValue")
  334. Creator_Tag.Name = "creator"
  335. Creator_Tag.Value = player
  336. Debris:AddItem(Creator_Tag, 2)
  337. Creator_Tag.Parent = humanoid
  338. end
  339.  
  340. function UntagHumanoid(humanoid)
  341. for i, v in pairs(humanoid:GetChildren()) do
  342. if v:IsA("ObjectValue") and v.Name == "creator" then
  343. v:Destroy()
  344. end
  345. end
  346. end
  347.  
  348. function FindCharacterAncestor(Parent)
  349. if Parent and Parent ~= game:GetService("Workspace") then
  350. local humanoid = Parent:FindFirstChild("Humanoid")
  351. if humanoid then
  352. return Parent, humanoid
  353. else
  354. return FindCharacterAncestor(Parent.Parent)
  355. end
  356. end
  357. return nil
  358. end
  359.  
  360. function GetTransparentsRecursive(Parent, PartsTable)
  361. local PartsTable = (PartsTable or {})
  362. for i, v in pairs(Parent:GetChildren()) do
  363. local TransparencyExists = false
  364. pcall(function()
  365. local Transparency = v["Transparency"]
  366. if Transparency then
  367. TransparencyExists = true
  368. end
  369. end)
  370. if TransparencyExists then
  371. table.insert(PartsTable, v)
  372. end
  373. GetTransparentsRecursive(v, PartsTable)
  374. end
  375. return PartsTable
  376. end
  377.  
  378. function SelectionBoxify(Object)
  379. local SelectionBox = Instance.new("SelectionBox")
  380. SelectionBox.Adornee = Object
  381. SelectionBox.Color = BrickColor.new("Toothpaste")
  382. SelectionBox.Parent = Object
  383. return SelectionBox
  384. end
  385.  
  386. local function Light(Object)
  387. local Light = PointLight:Clone()
  388. Light.Range = (Light.Range + 2)
  389. Light.Parent = Object
  390. end
  391.  
  392. function FadeOutObjects(Objects, FadeIncrement)
  393. repeat
  394. local LastObject = nil
  395. for i, v in pairs(Objects) do
  396. v.Transparency = (v.Transparency + FadeIncrement)
  397. LastObject = v
  398. end
  399. wait()
  400. until LastObject.Transparency >= 1 or not LastObject
  401. end
  402.  
  403. function Dematerialize(character, humanoid, FirstPart)
  404. if not character or not humanoid then
  405. return
  406. end
  407.  
  408. humanoid.WalkSpeed = 0
  409.  
  410. local Parts = {}
  411.  
  412. for i, v in pairs(character:GetChildren()) do
  413. if v:IsA("BasePart") then
  414. v.Anchored = true
  415. table.insert(Parts, v)
  416. elseif v:IsA("LocalScript") or v:IsA("Script") then
  417. v:Destroy()
  418. end
  419. end
  420.  
  421. local SelectionBoxes = {}
  422.  
  423. local FirstSelectionBox = SelectionBoxify(FirstPart)
  424. Light(FirstPart)
  425. wait(0.05)
  426.  
  427. for i, v in pairs(Parts) do
  428. if v ~= FirstPart then
  429. table.insert(SelectionBoxes, SelectionBoxify(v))
  430. Light(v)
  431. end
  432. end
  433.  
  434. local ObjectsWithTransparency = GetTransparentsRecursive(character)
  435. FadeOutObjects(ObjectsWithTransparency, 0.1)
  436.  
  437. wait(0.5)
  438.  
  439. character:BreakJoints()
  440. humanoid.Health = 0
  441.  
  442. Debris:AddItem(character, 2)
  443.  
  444. local FadeIncrement = 0.05
  445. Delay(0.2, function()
  446. FadeOutObjects({FirstSelectionBox}, FadeIncrement)
  447. if character and character.Parent then
  448. character:Destroy()
  449. end
  450. end)
  451. FadeOutObjects(SelectionBoxes, FadeIncrement)
  452. end
  453.  
  454. function Touched(Projectile, Hit)
  455. if not Hit or not Hit.Parent then
  456. return
  457. end
  458. local character, humanoid = FindCharacterAncestor(Hit)
  459. if character and humanoid and character ~= Character then
  460. local ForceFieldExists = false
  461. for i, v in pairs(character:GetChildren()) do
  462. if v:IsA("ForceField") then
  463. ForceFieldExists = true
  464. end
  465. end
  466. if not ForceFieldExists then
  467. if Projectile then
  468. local HitFadeSound = Projectile:FindFirstChild(Sounds.HitFade.Name)
  469. local torso = humanoid.Torso
  470. if HitFadeSound and torso then
  471. HitFadeSound.Parent = torso
  472. HitFadeSound:Play()
  473. end
  474. end
  475. Dematerialize(character, humanoid, Hit)
  476. end
  477. if Projectile and Projectile.Parent then
  478. Projectile:Destroy()
  479. end
  480. end
  481. end
  482.  
  483. function Equipped()
  484. Character = Tool.Parent
  485. Player = Players:GetPlayerFromCharacter(Character)
  486. Humanoid = Character:FindFirstChild("Humanoid")
  487. if not Player or not Humanoid or Humanoid.Health == 0 then
  488. return
  489. end
  490. end
  491.  
  492. function Activated(target)
  493. if Tool.Enabled and Humanoid.Health > 0 then
  494. Tool.Enabled = false
  495.  
  496. InvokeClient("PlaySound", Sounds.Fire)
  497.  
  498. local HandleCFrame = Handle.CFrame
  499. local FiringPoint = HandleCFrame.p + HandleCFrame:vectorToWorldSpace(NozzleOffset)
  500. local ShotCFrame = CFrame.new(FiringPoint, target)
  501.  
  502. local LaserShotClone = BaseShot:Clone()
  503. LaserShotClone.CFrame = ShotCFrame + (ShotCFrame.lookVector * (BaseShot.Size.Z / 2))
  504. local BodyVelocity = Instance.new("BodyVelocity")
  505. BodyVelocity.velocity = ShotCFrame.lookVector * Speed
  506. BodyVelocity.Parent = LaserShotClone
  507. LaserShotClone.Touched:connect(function(Hit)
  508. if not Hit or not Hit.Parent then
  509. return
  510. end
  511. Touched(LaserShotClone, Hit)
  512. end)
  513. Debris:AddItem(LaserShotClone, Duration)
  514. LaserShotClone.Parent = game:GetService("Workspace")
  515.  
  516. wait(0.6) -- FireSound length
  517.  
  518. InvokeClient("PlaySound", Sounds.Reload)
  519.  
  520. wait(0.75) -- ReloadSound length
  521.  
  522. Tool.Enabled = true
  523. end
  524. end
  525.  
  526. function Unequipped()
  527.  
  528. end
  529.  
  530. BaseShot = Instance.new("Part")
  531. BaseShot.Name = "Effect"
  532. BaseShot.BrickColor = BrickColor.new("Toothpaste")
  533. BaseShot.Material = Enum.Material.Plastic
  534. BaseShot.Shape = Enum.PartType.Block
  535. BaseShot.TopSurface = Enum.SurfaceType.Smooth
  536. BaseShot.BottomSurface = Enum.SurfaceType.Smooth
  537. BaseShot.FormFactor = Enum.FormFactor.Custom
  538. BaseShot.Size = Vector3.new(0.2, 0.2, 3)
  539. BaseShot.CanCollide = false
  540. BaseShot.Locked = true
  541. SelectionBoxify(BaseShot)
  542. Light(BaseShot)
  543. BaseShotSound = Sounds.HitFade:Clone()
  544. BaseShotSound.Parent = BaseShot
  545.  
  546. Tool.Equipped:connect(Equipped)
  547. Tool.Unequipped:connect(Unequipped)
  548. end))
  549. for i,v in pairs(mas:GetChildren()) do
  550. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  551. pcall(function() v:MakeJoints() end)
  552. end
  553. mas:Destroy()
  554. for i,v in pairs(cors) do
  555. spawn(function()
  556. pcall(v)
  557. end)
  558. end
Add Comment
Please, Sign In to add comment