Advertisement
Guest User

FE portal gun script

a guest
Jan 19th, 2019
1,280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.63 KB | None | 0 0
  1. --https://github.com/Mokiros/roblox-FE-compatibility
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,game,owner = owner,game
  4. local RealPlayer = Player
  5. do print("FE Compatibility code V2 by Mokiros")local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end
  6.  
  7. mouse = game.Players.LocalPlayer:GetMouse()
  8. gun = Instance.new("Part", game.Players.LocalPlayer.Character)
  9. gun.Size = Vector3.new(0.5, 1, 2)
  10. gun.CanCollide = false
  11. gun:BreakJoints()
  12. weld = Instance.new("Weld", gun)
  13. weld.Part0 = game.Players.LocalPlayer.Character["Right Arm"]
  14. weld.Part1 = gun
  15. mesh = Instance.new("SpecialMesh", gun)
  16. mesh.MeshId = "rbxassetid://430056568"
  17. mesh.TextureId = "rbxassetid://430056584"
  18. portalmoosic = Instance.new("Sound", game.Players.LocalPlayer.Character)
  19. portalmoosic.SoundId = "rbxassetid://142300248"
  20. portalmoosic.Looped = true
  21. portalmoosic:Play()
  22. impact = Instance.new("Sound", game.Players.LocalPlayer.Character)
  23. impact.SoundId = "rbxassetid://142082170"
  24. mesh.Scale = Vector3.new(0.17,0.17,0.17)
  25. weld.C0 = weld.C0 * CFrame.new(-0.2,-1.3,-0.8) * CFrame.Angles(3,0,0)
  26. local rhandweld = Instance.new("Weld", game.Players.LocalPlayer.Character.Torso)
  27. rhandweld.Part0 = game.Players.LocalPlayer.Character.Torso
  28. rhandweld.Part1 = game.Players.LocalPlayer.Character["Right Arm"]
  29. rhandweld.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  30. rhandweld.C1 = CFrame.new(0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  31. local lhandweld = Instance.new("Weld", game.Players.LocalPlayer.Character.Torso)
  32. lhandweld.Part0 = game.Players.LocalPlayer.Character.Torso
  33. lhandweld.Part1 = game.Players.LocalPlayer.Character["Left Arm"]
  34. lhandweld.C0 = CFrame.new(-1.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  35. lhandweld.C1 = CFrame.new(0, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  36. Pick = Instance.new("Sound", gun)
  37. Pick.SoundId = "rbxassetid://291256829"
  38. Pick:Play()
  39. Shoot = Instance.new("Sound", gun)
  40. Shoot.SoundId = "rbxassetid://142774034"
  41. blueexists = false
  42. tping = false
  43. orangeexists = false
  44. for i = 0,1 , 0.1 do
  45. wait()
  46. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,-0.2,-0.28),i)
  47. rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.28),i)
  48. end
  49. for i = 0,1 , 0.1 do
  50. wait()
  51. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.new(0,-0.25,0),i)
  52. end
  53. using = false
  54. orange = false
  55. blue = true
  56. function changeportals(key)
  57. key = key:lower()
  58. if key == "q" then
  59. if not blue then
  60. blue = true
  61. orange = false
  62. end
  63. end
  64. if key == "e" then
  65. if not orange then
  66. blue = false
  67. orange = true
  68. end
  69. end
  70. end
  71. function portal()
  72. if not using then
  73. using = true
  74. if blue then
  75. Shoot:Play()
  76. local projectile = Instance.new("Part", workspace)
  77. projectile.Size = Vector3.new(1,1,1)
  78. projectile.BrickColor = BrickColor.new("Electric blue")
  79. projectile.Shape = "Ball"
  80. projectile.CanCollide = true
  81. projectile.Anchored = false
  82. projectile.Material = "Neon"
  83. local vel = Instance.new("BodyVelocity", projectile)
  84. vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  85. vel.Velocity = mouse.Hit.lookVector * 80
  86. projectile.Position = gun.CFrame.p
  87. wait(0.03)
  88. local function make(part)
  89. local gr = part.Parent:findFirstChild("Part")
  90. local porjectileposition = projectile.Position
  91. local portaldoor = Instance.new("Part", workspace)
  92. portaldoor.Size = Vector3.new(1, 1, 1)
  93. portaldoor.BrickColor = BrickColor.new("Electric blue")
  94. portaldoor.Anchored = true
  95. portaldoor.Shape = "Cylinder"
  96. portaldoor.Material = "Neon"
  97. portaldoor.CanCollide = false
  98. if blueexists == true then
  99. workspace.BluePortal:destroy()
  100. end
  101. blueexists = true
  102. portaldoor.Name = "BluePortal"
  103. portaldoor.CFrame = part.CFrame
  104. if part.Size.y < part.Size.x and part.Size.y < part.Size.z then --a big help from Toxsikkilla
  105. print("if y < x")
  106. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0,0,math.pi / 2)
  107. elseif part.Size.x < part.Size.y and part.Size.x < part.Size.z then
  108. print("if x < y")
  109. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
  110. elseif part.Size.z < part.Size.y and part.Size.z < part.Size.y then
  111. print("if z < y")
  112. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0, math.pi / 2, 0)
  113. end
  114. portaldoor.Position = projectile.Position
  115. projectile:destroy()
  116. for i = 1,18 do
  117. portaldoor.Size = portaldoor.Size + Vector3.new(0,0.3,0.3)
  118. wait()
  119. end
  120. local function tp(part)
  121. local hum = part.Parent:findFirstChild("Humanoid")
  122. if hum ~= nil and blueexists and orangeexists and not tping then
  123. tping = true
  124. local tor = part.Parent:findFirstChild("Torso")
  125. if tor then
  126. local velocityoftorso = tor.Velocity
  127. local blport = workspace:findFirstChild("OrangePortal")
  128. if blport then
  129. tor.CFrame = workspace.OrangePortal.CFrame
  130. tor.Velocity = workspace.OrangePortal.CFrame.rightVector * -velocityoftorso * 1.7
  131. end
  132. end
  133. wait(0.3)
  134. tping = false
  135. end
  136. if not hum and blueexists and orangeexists and not tping then
  137. tping = true
  138. local cube = part.Parent:findFirstChild("Cube")
  139. if cube then
  140. tping = true
  141. local velocityoftorso = cube.Velocity
  142. cube.CFrame = workspace.OrangePortal.CFrame
  143. cube.Velocity = workspace.OrangePortal.CFrame.rightVector * -velocityoftorso * 1.7
  144. wait(0.3)
  145. tping = false
  146. end
  147. end
  148. wait(0.3)
  149. tping = false
  150. end
  151. portaldoor.Touched:connect(tp)
  152. end
  153. projectile.Touched:connect(make)
  154. end
  155. if orange then
  156. Shoot:Play()
  157. local projectile1 = Instance.new("Part", workspace)
  158. projectile1.Size = Vector3.new(1,1,1)
  159. projectile1.BrickColor = BrickColor.new("Deep orange")
  160. projectile1.Shape = "Ball"
  161. projectile1.CanCollide = true
  162. projectile1.Anchored = false
  163. projectile1.Material = "Neon"
  164. local vel1 = Instance.new("BodyVelocity", projectile1)
  165. vel1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  166. vel1.Velocity = mouse.Hit.lookVector * 80
  167. projectile1.Position = gun.CFrame.p
  168. wait(0.03)
  169. local function make1(part)
  170. local gr = part.Parent:findFirstChild("Part")
  171. local portaldoor = Instance.new("Part", workspace)
  172. portaldoor.Size = Vector3.new(1, 1, 1)
  173. portaldoor.BrickColor = BrickColor.new("Deep orange")
  174. portaldoor.Anchored = true
  175. portaldoor.Material = "Neon"
  176. portaldoor.Shape = "Cylinder"
  177. portaldoor.CanCollide = false
  178. if orangeexists == true then
  179. workspace.OrangePortal:destroy()
  180. end
  181. portaldoor.CFrame = part.CFrame
  182. if part.Size.y < part.Size.x and part.Size.y < part.Size.z then --a big help from Toxsikkilla
  183. print("if y < x")
  184. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0,0,math.pi / 2)
  185. elseif part.Size.x < part.Size.y and part.Size.x < part.Size.z then
  186. print("if x < y")
  187. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
  188. elseif part.Size.z < part.Size.y and part.Size.z < part.Size.y then
  189. print("if z < y")
  190. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0, math.pi / 2, 0)
  191. end
  192. portaldoor.Position = projectile1.Position
  193. projectile1:destroy()
  194. for i = 1,18 do
  195. portaldoor.Size = portaldoor.Size + Vector3.new(0,0.3,0.3)
  196. wait()
  197. end
  198. orangeexists = true
  199. portaldoor.Name = "OrangePortal"
  200. local function tp(part)
  201. local hum = part.Parent:findFirstChild("Humanoid")
  202. if hum ~= nil and blueexists and orangeexists and not tping then
  203. tping = true
  204. local tor = part.Parent:findFirstChild("Torso")
  205. if tor then
  206. local velocityoftorso = tor.Velocity
  207. local blport = workspace:findFirstChild("BluePortal")
  208. if blport then
  209. tor.CFrame = workspace.BluePortal.CFrame
  210. tor.Velocity = workspace.BluePortal.CFrame.rightVector * -velocityoftorso * 1.7
  211. end
  212. end
  213. wait(0.3)
  214. tping = false
  215. end
  216. if not hum and blueexists and orangeexists and not tping then
  217. tping = true
  218. local cube = part.Parent:findFirstChild("Cube")
  219. if cube then
  220. tping = true
  221. local velocityoftorso = cube.Velocity
  222. local blport = workspace:findFirstChild("BluePortal")
  223. if velocityoftorso.y < velocityoftorso.z and velocityoftorso.y < velocityoftorso.x then
  224. cube.Velocity = -velocityoftorso * 1.5
  225. if blport then
  226. cube.CFrame = workspace.BluePortal.rightVector * -velocityoftorso * 1.7
  227. end
  228. end
  229. wait(0.3)
  230. tping = false
  231. end
  232. wait(0.3)
  233. tping = false
  234. end
  235. wait(0.3)
  236. tping = false
  237. end
  238. portaldoor.Touched:connect(tp)
  239. end
  240. projectile1.Touched:connect(make1)
  241. end
  242.  
  243. for i = 0,1 , 0.3 do
  244. wait()
  245. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,-0.2),i)
  246. rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.2),i)
  247. end
  248. for i = 0,1 , 0.3 do
  249. wait()
  250. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.2),i)
  251. rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,-0.2),i)
  252. end
  253. using = false
  254. end
  255. end
  256. function remove(key)
  257. key = key:lower()
  258. if key == "r" then
  259. if blueexists or orangeexists or blueexists and orangeexists then
  260. workspace.OrangePortal:destroy()
  261. workspace.BluePortal:destroy()
  262. orangeexists = false
  263. blueexists = false
  264. end
  265. end
  266. end
  267. impacting = false
  268. cubesp = false
  269. function cubespawn(key)
  270. key = key:lower()
  271. if key == "c" then
  272. if cubesp then
  273. workspace.Cube:destroy()
  274. end
  275. cubesp = true
  276. local coobe = Instance.new("Part", workspace)
  277. coobe.Size = Vector3.new(2.774, 2.834, 2.804)
  278. coobe:BreakJoints()
  279. coobe.Position = game.Players.LocalPlayer.Character.Torso.Position
  280. coobe.Name = "Cube"
  281. local meh = Instance.new("SpecialMesh", coobe)
  282. meh.MeshId = "rbxassetid://464957313"
  283. meh.TextureId = "rbxassetid://464957325"
  284. meh.Scale = Vector3.new(0.8,0.8,0.8)
  285. local function sounds()
  286. if not impacting then
  287. impacting = true
  288. local impactspeed = math.random(0.9,1.1)
  289. impact.PlaybackSpeed = impactspeed
  290. impact:Play()
  291. wait(0.2)
  292. impacting = false
  293. end
  294. end
  295. coobe.Touched:connect(sounds)
  296. end
  297. end
  298. function deleterportalsondedth()
  299. if orangeexists or blueexists or blueexists and orangeexists then
  300. workspace.OrangePortal:destroy()
  301. workspace.BluePortal:destroy()
  302. if cubesp then
  303. workspace.Cube:destroy()
  304. end
  305. end
  306. end
  307. game.Players.LocalPlayer.Character.Humanoid.Died:connect(deleterportalsondedth)
  308. mouse.KeyDown:connect(cubespawn)
  309. mouse.Button1Down:connect(portal)
  310. mouse.KeyDown:connect(changeportals)
  311. mouse.KeyDown:connect(remove)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement