Advertisement
DarkScriptZEditors

Untitled

Dec 30th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.12 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(),Button2Up=fakeEvent(),Button2Down=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. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  51. return m:TrigEvent(b and "Button2Down" or "Button2Up")
  52. end
  53. for _,t in pairs(CAS.Actions) do
  54. for _,k in pairs(t.Keys) do
  55. if k==io.KeyCode then
  56. t.Function(t.Name,io.UserInputState,io)
  57. end
  58. end
  59. end
  60. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  61. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  62. end
  63. end)
  64. Event.Parent = NLS([==[
  65. local Player = game:GetService("Players").LocalPlayer
  66. local Event = script:WaitForChild("UserInput_Event")
  67. local Mouse = Player:GetMouse()
  68. local UIS = game:GetService("UserInputService")
  69. local input = function(io,a)
  70. if a then return end
  71. --Since InputObject is a client-side instance, we create and pass table instead
  72. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  73. end
  74. UIS.InputBegan:Connect(input)
  75. UIS.InputEnded:Connect(input)
  76. local h,t
  77. --Give the server mouse data 30 times every second, but only if the values changed
  78. --If player is not moving their mouse, client won't fire events
  79. while wait(1/30) do
  80. if h~=Mouse.Hit or t~=Mouse.Target then
  81. h,t=Mouse.Hit,Mouse.Target
  82. Event:FireServer({isMouse=true,Target=t,Hit=h})
  83. end
  84. end]==],Player.Character)
  85.  
  86. ----Sandboxed game object that allows the usage of client-side methods and services
  87. --Real game object
  88. local _rg = game
  89.  
  90. --Metatable for fake service
  91. local fsmt = {
  92. __index = function(self,k)
  93. local s = rawget(self,"_RealService")
  94. if s then
  95. return typeof(s[k])=="function"
  96. and function(_,...)return s[k](s,...)end or s[k]
  97. end
  98. end,
  99. __newindex = function(self,k,v)
  100. local s = rawget(self,"_RealService")
  101. if s then s[k]=v 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 rawget(self,s) or _rg:GetService(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. RunService = FakeService({
  120. _btrs = {},
  121. RenderStepped = _rg:GetService("RunService").Heartbeat,
  122. BindToRenderStep = function(self,name,_,fun)
  123. self._btrs[name] = self.Heartbeat:Connect(fun)
  124. end,
  125. UnbindFromRenderStep = function(self,name)
  126. self._btrs[name]:Disconnect()
  127. end,
  128. },"RunService")
  129. }
  130. rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  131. g.service = g.GetService
  132. FakeService(g,game)
  133. --Changing owner to fake player object to support owner:GetMouse()
  134. game,owner = g,g.Players.LocalPlayer
  135. end
  136. mouse = game.Players.LocalPlayer:GetMouse()
  137. gun = Instance.new("Part", game.Players.LocalPlayer.Character)
  138. gun.Size = Vector3.new(0.5, 1, 2)
  139. gun.CanCollide = false
  140. gun:BreakJoints()
  141. weld = Instance.new("Weld", gun)
  142. weld.Part0 = game.Players.LocalPlayer.Character["Right Arm"]
  143. weld.Part1 = gun
  144. mesh = Instance.new("SpecialMesh", gun)
  145. mesh.MeshId = "rbxassetid://430056568"
  146. mesh.TextureId = "rbxassetid://430056584"
  147. portalmoosic = Instance.new("Sound", game.Players.LocalPlayer.Character)
  148. portalmoosic.SoundId = "rbxassetid://2174350733"
  149. portalmoosic.Looped = true
  150. portalmoosic:Play()
  151. impact = Instance.new("Sound", game.Players.LocalPlayer.Character)
  152. impact.SoundId = "rbxassetid://142082170"
  153. mesh.Scale = Vector3.new(0.17,0.17,0.17)
  154. weld.C0 = weld.C0 * CFrame.new(-0.2,-1.3,-0.8) * CFrame.Angles(3,0,0)
  155. local rhandweld = Instance.new("Weld", game.Players.LocalPlayer.Character.Torso)
  156. rhandweld.Part0 = game.Players.LocalPlayer.Character.Torso
  157. rhandweld.Part1 = game.Players.LocalPlayer.Character["Right Arm"]
  158. rhandweld.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  159. rhandweld.C1 = CFrame.new(0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  160. local lhandweld = Instance.new("Weld", game.Players.LocalPlayer.Character.Torso)
  161. lhandweld.Part0 = game.Players.LocalPlayer.Character.Torso
  162. lhandweld.Part1 = game.Players.LocalPlayer.Character["Left Arm"]
  163. lhandweld.C0 = CFrame.new(-1.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  164. lhandweld.C1 = CFrame.new(0, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  165. Pick = Instance.new("Sound", gun)
  166. Pick.SoundId = "rbxassetid://291256829"
  167. Pick:Play()
  168. Shoot = Instance.new("Sound", gun)
  169. Shoot.SoundId = "rbxassetid://142774034"
  170. blueexists = false
  171. tping = false
  172. orangeexists = false
  173. for i = 0,1 , 0.1 do
  174. wait()
  175. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,-0.2,-0.28),i)
  176. rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.28),i)
  177. end
  178. for i = 0,1 , 0.1 do
  179. wait()
  180. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.new(0,-0.25,0),i)
  181. end
  182. using = false
  183. orange = false
  184. blue = true
  185. function changeportals(key)
  186. key = key:lower()
  187. if key == "q" then
  188. if not blue then
  189. blue = true
  190. orange = false
  191. end
  192. end
  193. if key == "e" then
  194. if not orange then
  195. blue = false
  196. orange = true
  197. end
  198. end
  199. end
  200. function portal()
  201. if not using then
  202. using = true
  203. if blue then
  204. Shoot:Play()
  205. local projectile = Instance.new("Part", workspace)
  206. projectile.Size = Vector3.new(1,1,1)
  207. projectile.BrickColor = BrickColor.new("Electric blue")
  208. projectile.Shape = "Ball"
  209. projectile.CanCollide = true
  210. projectile.Anchored = false
  211. projectile.Material = "Neon"
  212. local vel = Instance.new("BodyVelocity", projectile)
  213. vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  214. vel.Velocity = mouse.Hit.lookVector * 80
  215. projectile.Position = gun.CFrame.p
  216. wait(0.03)
  217. local function make(part)
  218. local gr = part.Parent:findFirstChild("Part")
  219. local porjectileposition = projectile.Position
  220. local portaldoor = Instance.new("Part", workspace)
  221. portaldoor.Size = Vector3.new(1, 1, 1)
  222. portaldoor.BrickColor = BrickColor.new("Electric blue")
  223. portaldoor.Anchored = true
  224. portaldoor.Shape = "Cylinder"
  225. portaldoor.Material = "Neon"
  226. portaldoor.CanCollide = false
  227. if blueexists == true then
  228. workspace.BluePortal:destroy()
  229. end
  230. blueexists = true
  231. portaldoor.Name = "BluePortal"
  232. portaldoor.CFrame = part.CFrame
  233. if part.Size.y < part.Size.x and part.Size.y < part.Size.z then --a big help from Toxsikkilla
  234. print("if y < x")
  235. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0,0,math.pi / 2)
  236. elseif part.Size.x < part.Size.y and part.Size.x < part.Size.z then
  237. print("if x < y")
  238. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
  239. elseif part.Size.z < part.Size.y and part.Size.z < part.Size.y then
  240. print("if z < y")
  241. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0, math.pi / 2, 0)
  242. end
  243. portaldoor.Position = projectile.Position
  244. projectile:destroy()
  245. for i = 1,18 do
  246. portaldoor.Size = portaldoor.Size + Vector3.new(0,0.3,0.3)
  247. wait()
  248. end
  249. local function tp(part)
  250. local hum = part.Parent:findFirstChild("Humanoid")
  251. if hum ~= nil and blueexists and orangeexists and not tping then
  252. tping = true
  253. local tor = part.Parent:findFirstChild("Torso")
  254. if tor then
  255. local velocityoftorso = tor.Velocity
  256. local blport = workspace:findFirstChild("OrangePortal")
  257. if blport then
  258. tor.CFrame = workspace.OrangePortal.CFrame
  259. tor.Velocity = workspace.OrangePortal.CFrame.rightVector * -velocityoftorso * 1.7
  260. end
  261. end
  262. wait(0.3)
  263. tping = false
  264. end
  265. if not hum and blueexists and orangeexists and not tping then
  266. tping = true
  267. local cube = part.Parent:findFirstChild("Cube")
  268. if cube then
  269. tping = true
  270. local velocityoftorso = cube.Velocity
  271. cube.CFrame = workspace.OrangePortal.CFrame
  272. cube.Velocity = workspace.OrangePortal.CFrame.rightVector * -velocityoftorso * 1.7
  273. wait(0.3)
  274. tping = false
  275. end
  276. end
  277. wait(0.3)
  278. tping = false
  279. end
  280. portaldoor.Touched:connect(tp)
  281. end
  282. projectile.Touched:connect(make)
  283. end
  284. if orange then
  285. Shoot:Play()
  286. local projectile1 = Instance.new("Part", workspace)
  287. projectile1.Size = Vector3.new(1,1,1)
  288. projectile1.BrickColor = BrickColor.new("Deep orange")
  289. projectile1.Shape = "Ball"
  290. projectile1.CanCollide = true
  291. projectile1.Anchored = false
  292. projectile1.Material = "Neon"
  293. local vel1 = Instance.new("BodyVelocity", projectile1)
  294. vel1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  295. vel1.Velocity = mouse.Hit.lookVector * 80
  296. projectile1.Position = gun.CFrame.p
  297. wait(0.03)
  298. local function make1(part)
  299. local gr = part.Parent:findFirstChild("Part")
  300. local portaldoor = Instance.new("Part", workspace)
  301. portaldoor.Size = Vector3.new(1, 1, 1)
  302. portaldoor.BrickColor = BrickColor.new("Deep orange")
  303. portaldoor.Anchored = true
  304. portaldoor.Material = "Neon"
  305. portaldoor.Shape = "Cylinder"
  306. portaldoor.CanCollide = false
  307. if orangeexists == true then
  308. workspace.OrangePortal:destroy()
  309. end
  310. portaldoor.CFrame = part.CFrame
  311. if part.Size.y < part.Size.x and part.Size.y < part.Size.z then --a big help from Toxsikkilla
  312. print("if y < x")
  313. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0,0,math.pi / 2)
  314. elseif part.Size.x < part.Size.y and part.Size.x < part.Size.z then
  315. print("if x < y")
  316. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
  317. elseif part.Size.z < part.Size.y and part.Size.z < part.Size.y then
  318. print("if z < y")
  319. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0, math.pi / 2, 0)
  320. end
  321. portaldoor.Position = projectile1.Position
  322. projectile1:destroy()
  323. for i = 1,18 do
  324. portaldoor.Size = portaldoor.Size + Vector3.new(0,0.3,0.3)
  325. wait()
  326. end
  327. orangeexists = true
  328. portaldoor.Name = "OrangePortal"
  329. local function tp(part)
  330. local hum = part.Parent:findFirstChild("Humanoid")
  331. if hum ~= nil and blueexists and orangeexists and not tping then
  332. tping = true
  333. local tor = part.Parent:findFirstChild("Torso")
  334. if tor then
  335. local velocityoftorso = tor.Velocity
  336. local blport = workspace:findFirstChild("BluePortal")
  337. if blport then
  338. tor.CFrame = workspace.BluePortal.CFrame
  339. tor.Velocity = workspace.BluePortal.CFrame.rightVector * -velocityoftorso * 1.7
  340. end
  341. end
  342. wait(0.3)
  343. tping = false
  344. end
  345. if not hum and blueexists and orangeexists and not tping then
  346. tping = true
  347. local cube = part.Parent:findFirstChild("Cube")
  348. if cube then
  349. tping = true
  350. local velocityoftorso = cube.Velocity
  351. local blport = workspace:findFirstChild("BluePortal")
  352. if velocityoftorso.y < velocityoftorso.z and velocityoftorso.y < velocityoftorso.x then
  353. cube.Velocity = -velocityoftorso * 1.5
  354. if blport then
  355. cube.CFrame = workspace.BluePortal.rightVector * -velocityoftorso * 1.7
  356. end
  357. end
  358. wait(0.3)
  359. tping = false
  360. end
  361. wait(0.3)
  362. tping = false
  363. end
  364. wait(0.3)
  365. tping = false
  366. end
  367. portaldoor.Touched:connect(tp)
  368. end
  369. projectile1.Touched:connect(make1)
  370. end
  371.  
  372. for i = 0,1 , 0.3 do
  373. wait()
  374. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,-0.2),i)
  375. rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.2),i)
  376. end
  377. for i = 0,1 , 0.3 do
  378. wait()
  379. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.2),i)
  380. rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,-0.2),i)
  381. end
  382. using = false
  383. end
  384. end
  385. function remove(key)
  386. key = key:lower()
  387. if key == "r" then
  388. if blueexists or orangeexists or blueexists and orangeexists then
  389. workspace.OrangePortal:destroy()
  390. workspace.BluePortal:destroy()
  391. orangeexists = false
  392. blueexists = false
  393. end
  394. end
  395. end
  396. impacting = false
  397. cubesp = false
  398. function cubespawn(key)
  399. key = key:lower()
  400. if key == "c" then
  401. if cubesp then
  402. workspace.Cube:destroy()
  403. end
  404. cubesp = true
  405. local coobe = Instance.new("Part", workspace)
  406. coobe.Size = Vector3.new(2.774, 2.834, 2.804)
  407. coobe:BreakJoints()
  408. coobe.Position = game.Players.LocalPlayer.Character.Torso.Position
  409. coobe.Name = "Cube"
  410. local meh = Instance.new("SpecialMesh", coobe)
  411. meh.MeshId = "rbxassetid://464957313"
  412. meh.TextureId = "rbxassetid://464957325"
  413. meh.Scale = Vector3.new(0.8,0.8,0.8)
  414. local function sounds()
  415. if not impacting then
  416. impacting = true
  417. local impactspeed = math.random(0.9,1.1)
  418. impact.PlaybackSpeed = impactspeed
  419. impact:Play()
  420. wait(0.2)
  421. impacting = false
  422. end
  423. end
  424. coobe.Touched:connect(sounds)
  425. end
  426. end
  427. function deleterportalsondedth()
  428. if orangeexists or blueexists or blueexists and orangeexists then
  429. workspace.OrangePortal:destroy()
  430. workspace.BluePortal:destroy()
  431. if cubesp then
  432. workspace.Cube:destroy()
  433. end
  434. end
  435. end
  436. game.Players.LocalPlayer.Character.Humanoid.Died:connect(deleterportalsondedth)
  437. mouse.KeyDown:connect(cubespawn)
  438. mouse.Button1Down:connect(portal)
  439. mouse.KeyDown:connect(changeportals)
  440. mouse.KeyDown:connect(remove)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement