Advertisement
HuyEvilDumb

portal gun (the last one was a failure dont use pls)

Jun 20th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CV="White"
  2.  
  3. p = game.Players.LocalPlayer
  4. char = p.Character
  5. local txt = Instance.new("BillboardGui", char)
  6. txt.Adornee = char .Head
  7. txt.Name = "_status"
  8. txt.Size = UDim2.new(2, 0, 1.2, 0)
  9. txt.StudsOffset = Vector3.new(-9, 8, 0)
  10. local text = Instance.new("TextLabel", txt)
  11. text.Size = UDim2.new(10, 0, 7, 0)
  12. text.FontSize = "Size24"
  13. text.TextScaled = true
  14. text.TextTransparency = 0
  15. text.BackgroundTransparency = 1
  16. text.TextTransparency = 0
  17. text.TextStrokeTransparency = 1
  18. text.Font = "Arcade"
  19. text.TextStrokeColor3 = Color3.new(0,0,255)
  20.  
  21. v=Instance.new("Part")
  22. v.Name = "ColorBrick"
  23. v.Parent=p.Character
  24. v.FormFactor="Symmetric"
  25. v.Anchored=true
  26. v.CanCollide=false
  27. v.BottomSurface="Smooth"
  28. v.TopSurface="Smooth"
  29. v.Size=Vector3.new(10,5,3)
  30. v.Transparency=1
  31. v.CFrame=char.Torso.CFrame
  32. v.BrickColor=BrickColor.new(CV)
  33. v.Transparency=1
  34. text.TextColor3 = Color3.new(255,255,0)
  35. v.Shape="Block"
  36. text.Text = "The Portal Gunner"
  37. mouse = game.Players.LocalPlayer:GetMouse()
  38. gun = Instance.new("Part", game.Players.LocalPlayer.Character)
  39. gun.Size = Vector3.new(0.5, 1, 2)
  40. gun.CanCollide = false
  41. gun:BreakJoints()
  42. weld = Instance.new("Weld", gun)
  43. weld.Part0 = game.Players.LocalPlayer.Character["Right Arm"]
  44. weld.Part1 = gun
  45. mesh = Instance.new("SpecialMesh", gun)
  46. mesh.MeshId = "rbxassetid://430056568"
  47. mesh.TextureId = "rbxassetid://430056584"
  48. portalmoosic = Instance.new("Sound", game.Players.LocalPlayer.Character)
  49. portalmoosic.SoundId = "rbxassetid://146830287"
  50. portalmoosic.Volume = 10
  51. portalmoosic.Looped = true
  52. portalmoosic:Play()
  53. impact = Instance.new("Sound", game.Players.LocalPlayer.Character)
  54. impact.SoundId = "rbxassetid://142082170"
  55. mesh.Scale = Vector3.new(0.17,0.17,0.17)
  56. weld.C0 = weld.C0 * CFrame.new(-0.2,-1.3,-0.8) * CFrame.Angles(3,0,0)
  57. local rhandweld = Instance.new("Weld", game.Players.LocalPlayer.Character.Torso)
  58. rhandweld.Part0 = game.Players.LocalPlayer.Character.Torso
  59. rhandweld.Part1 = game.Players.LocalPlayer.Character["Right Arm"]
  60. rhandweld.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  61. rhandweld.C1 = CFrame.new(0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  62. local lhandweld = Instance.new("Weld", game.Players.LocalPlayer.Character.Torso)
  63. lhandweld.Part0 = game.Players.LocalPlayer.Character.Torso
  64. lhandweld.Part1 = game.Players.LocalPlayer.Character["Left Arm"]
  65. lhandweld.C0 = CFrame.new(-1.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  66. lhandweld.C1 = CFrame.new(0, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  67. Pick = Instance.new("Sound", gun)
  68. Pick.SoundId = "rbxassetid://291256829"
  69. Pick:Play()
  70. Shoot = Instance.new("Sound", gun)
  71. Shoot.SoundId = "rbxassetid://142774034"
  72. blueexists = false
  73. tping = false
  74. orangeexists = false
  75. for i = 0,1 , 0.1 do
  76. wait()
  77. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,-0.2,-0.28),i)
  78. rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.28),i)
  79. end
  80. for i = 0,1 , 0.1 do
  81. wait()
  82. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.new(0,-0.25,0),i)
  83. end
  84. using = false
  85. orange = false
  86. blue = true
  87. function changeportals(key)
  88. key = key:lower()
  89. if key == "q" then
  90. if not blue then
  91. blue = true
  92. orange = false
  93. end
  94. end
  95. if key == "e" then
  96. if not orange then
  97. blue = false
  98. orange = true
  99. end
  100. end
  101. end
  102. function portal()
  103. if not using then
  104. using = true
  105. if blue then
  106. Shoot:Play()
  107. local projectile = Instance.new("Part", workspace)
  108. projectile.Size = Vector3.new(1,1,1)
  109. projectile.BrickColor = BrickColor.new("Electric blue")
  110. projectile.Shape = "Ball"
  111. projectile.CanCollide = true
  112. projectile.Anchored = false
  113. projectile.Material = "Neon"
  114. local vel = Instance.new("BodyVelocity", projectile)
  115. vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  116. vel.Velocity = mouse.Hit.lookVector * 80
  117. projectile.Position = gun.CFrame.p
  118. wait(0.03)
  119. local function make(part)
  120. local gr = part.Parent:findFirstChild("Part")
  121. local porjectileposition = projectile.Position
  122. local portaldoor = Instance.new("Part", workspace)
  123. portaldoor.Size = Vector3.new(1, 1, 1)
  124. portaldoor.BrickColor = BrickColor.new("Electric blue")
  125. portaldoor.Anchored = true
  126. portaldoor.Shape = "Cylinder"
  127. portaldoor.Material = "Neon"
  128. portaldoor.CanCollide = false
  129. if blueexists == true then
  130. workspace.BluePortal:destroy()
  131. end
  132. blueexists = true
  133. portaldoor.Name = "BluePortal"
  134. portaldoor.CFrame = part.CFrame
  135. if part.Size.y < part.Size.x and part.Size.y < part.Size.z then --a big help from Toxsikkilla
  136. print("if y < x")
  137. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0,0,math.pi / 2)
  138. elseif part.Size.x < part.Size.y and part.Size.x < part.Size.z then
  139. print("if x < y")
  140. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
  141. elseif part.Size.z < part.Size.y and part.Size.z < part.Size.y then
  142. print("if z < y")
  143. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0, math.pi / 2, 0)
  144. end
  145. portaldoor.Position = projectile.Position
  146. projectile:destroy()
  147. for i = 1,18 do
  148. portaldoor.Size = portaldoor.Size + Vector3.new(0,0.3,0.3)
  149. wait()
  150. end
  151. local function tp(part)
  152. local hum = part.Parent:findFirstChild("Humanoid")
  153. if hum ~= nil and blueexists and orangeexists and not tping then
  154. tping = true
  155. local tor = part.Parent:findFirstChild("Torso")
  156. if tor then
  157. local velocityoftorso = tor.Velocity
  158. local blport = workspace:findFirstChild("OrangePortal")
  159. if blport then
  160. tor.CFrame = workspace.OrangePortal.CFrame
  161. tor.Velocity = workspace.OrangePortal.CFrame.rightVector * -velocityoftorso * 1.7
  162. end
  163. end
  164. wait(0.3)
  165. tping = false
  166. end
  167. if not hum and blueexists and orangeexists and not tping then
  168. tping = true
  169. local cube = part.Parent:findFirstChild("Cube")
  170. if cube then
  171. tping = true
  172. local velocityoftorso = cube.Velocity
  173. cube.CFrame = workspace.OrangePortal.CFrame
  174. cube.Velocity = workspace.OrangePortal.CFrame.rightVector * -velocityoftorso * 1.7
  175. wait(0.3)
  176. tping = false
  177. end
  178. end
  179. wait(0.3)
  180. tping = false
  181. end
  182. portaldoor.Touched:connect(tp)
  183. end
  184. projectile.Touched:connect(make)
  185. end
  186. if orange then
  187. Shoot:Play()
  188. local projectile1 = Instance.new("Part", workspace)
  189. projectile1.Size = Vector3.new(1,1,1)
  190. projectile1.BrickColor = BrickColor.new("Deep orange")
  191. projectile1.Shape = "Ball"
  192. projectile1.CanCollide = true
  193. projectile1.Anchored = false
  194. projectile1.Material = "Neon"
  195. local vel1 = Instance.new("BodyVelocity", projectile1)
  196. vel1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  197. vel1.Velocity = mouse.Hit.lookVector * 80
  198. projectile1.Position = gun.CFrame.p
  199. wait(0.03)
  200. local function make1(part)
  201. local gr = part.Parent:findFirstChild("Part")
  202. local portaldoor = Instance.new("Part", workspace)
  203. portaldoor.Size = Vector3.new(1, 1, 1)
  204. portaldoor.BrickColor = BrickColor.new("Deep orange")
  205. portaldoor.Anchored = true
  206. portaldoor.Material = "Neon"
  207. portaldoor.Shape = "Cylinder"
  208. portaldoor.CanCollide = false
  209. if orangeexists == true then
  210. workspace.OrangePortal:destroy()
  211. end
  212. portaldoor.CFrame = part.CFrame
  213. if part.Size.y < part.Size.x and part.Size.y < part.Size.z then --a big help from Toxsikkilla
  214. print("if y < x")
  215. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0,0,math.pi / 2)
  216. elseif part.Size.x < part.Size.y and part.Size.x < part.Size.z then
  217. print("if x < y")
  218. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
  219. elseif part.Size.z < part.Size.y and part.Size.z < part.Size.y then
  220. print("if z < y")
  221. portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0, math.pi / 2, 0)
  222. end
  223. portaldoor.Position = projectile1.Position
  224. projectile1:destroy()
  225. for i = 1,18 do
  226. portaldoor.Size = portaldoor.Size + Vector3.new(0,0.3,0.3)
  227. wait()
  228. end
  229. orangeexists = true
  230. portaldoor.Name = "OrangePortal"
  231. local function tp(part)
  232. local hum = part.Parent:findFirstChild("Humanoid")
  233. if hum ~= nil and blueexists and orangeexists and not tping then
  234. tping = true
  235. local tor = part.Parent:findFirstChild("Torso")
  236. if tor then
  237. local velocityoftorso = tor.Velocity
  238. local blport = workspace:findFirstChild("BluePortal")
  239. if blport then
  240. tor.CFrame = workspace.BluePortal.CFrame
  241. tor.Velocity = workspace.BluePortal.CFrame.rightVector * -velocityoftorso * 1.7
  242. end
  243. end
  244. wait(0.3)
  245. tping = false
  246. end
  247. if not hum and blueexists and orangeexists and not tping then
  248. tping = true
  249. local cube = part.Parent:findFirstChild("Cube")
  250. if cube then
  251. tping = true
  252. local velocityoftorso = cube.Velocity
  253. local blport = workspace:findFirstChild("BluePortal")
  254. if velocityoftorso.y < velocityoftorso.z and velocityoftorso.y < velocityoftorso.x then
  255. cube.Velocity = -velocityoftorso * 1.5
  256. if blport then
  257. cube.CFrame = workspace.BluePortal.rightVector * -velocityoftorso * 1.7
  258. end
  259. end
  260. wait(0.3)
  261. tping = false
  262. end
  263. wait(0.3)
  264. tping = false
  265. end
  266. wait(0.3)
  267. tping = false
  268. end
  269. portaldoor.Touched:connect(tp)
  270. end
  271. projectile1.Touched:connect(make1)
  272. end
  273.  
  274. for i = 0,1 , 0.3 do
  275. wait()
  276. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,-0.2),i)
  277. rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.2),i)
  278. end
  279. for i = 0,1 , 0.3 do
  280. wait()
  281. lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.2),i)
  282. rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,-0.2),i)
  283. end
  284. using = false
  285. end
  286. end
  287. function remove(key)
  288. key = key:lower()
  289. if key == "r" then
  290. if blueexists or orangeexists or blueexists and orangeexists then
  291. workspace.OrangePortal:destroy()
  292. workspace.BluePortal:destroy()
  293. orangeexists = false
  294. blueexists = false
  295. end
  296. end
  297. end
  298. impacting = false
  299. cubesp = false
  300. function cubespawn(key)
  301. key = key:lower()
  302. if key == "c" then
  303. if cubesp then
  304. workspace.Cube:destroy()
  305. end
  306. cubesp = true
  307. local coobe = Instance.new("Part", workspace)
  308. coobe.Size = Vector3.new(2.774, 2.834, 2.804)
  309. coobe:BreakJoints()
  310. coobe.Position = game.Players.LocalPlayer.Character.Torso.Position
  311. coobe.Name = "Cube"
  312. local meh = Instance.new("SpecialMesh", coobe)
  313. meh.MeshId = "rbxassetid://464957313"
  314. meh.TextureId = "rbxassetid://464957325"
  315. meh.Scale = Vector3.new(0.8,0.8,0.8)
  316. local function sounds()
  317. if not impacting then
  318. impacting = true
  319. local impactspeed = math.random(0.9,1.1)
  320. impact.PlaybackSpeed = impactspeed
  321. impact:Play()
  322. wait(0.2)
  323. impacting = false
  324. end
  325. end
  326. coobe.Touched:connect(sounds)
  327. end
  328. end
  329. function deleterportalsondedth()
  330. if orangeexists or blueexists or blueexists and orangeexists then
  331. workspace.OrangePortal:destroy()
  332. workspace.BluePortal:destroy()
  333. if cubesp then
  334. workspace.Cube:destroy()
  335. end
  336. end
  337. end
  338. game.Players.LocalPlayer.Character.Humanoid.Died:connect(deleterportalsondedth)
  339. mouse.KeyDown:connect(cubespawn)
  340. mouse.Button1Down:connect(portal)
  341. mouse.KeyDown:connect(changeportals)
  342. mouse.KeyDown:connect(remove)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement