HuyEvilDumb

Portal Gun

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