memberhero

Portal Gun

Mar 4th, 2021 (edited)
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.52 KB | None | 0 0
  1. --Converted with ttyyuu12345's model to script plugin v4
  2. --By Rufus14
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Tool0 = Instance.new("Tool")
  20. Part1 = Instance.new("Part")
  21. SpecialMesh2 = Instance.new("SpecialMesh")
  22. Sound3 = Instance.new("Sound")
  23. Sound4 = Instance.new("Sound")
  24. Sound5 = Instance.new("Sound")
  25. Weld6 = Instance.new("Weld")
  26. LocalScript7 = Instance.new("LocalScript")
  27. RemoteEvent8 = Instance.new("RemoteEvent")
  28. Script9 = Instance.new("Script")
  29. Part10 = Instance.new("Part")
  30. Tool0.Name = "Portal Gun"
  31. Tool0.Parent = mas
  32. Part1.Name = "Handle"
  33. Part1.Parent = Tool0
  34. Part1.CFrame = CFrame.new(5.81662703, 0.500005007, -3.48566008, 1, 0, -0, 0, 0, 1, 0, -1, 0)
  35. Part1.Orientation = Vector3.new(-90, 0, 0)
  36. Part1.Position = Vector3.new(5.81662703, 0.500005007, -3.48566008)
  37. Part1.Rotation = Vector3.new(-90, 0, 0)
  38. Part1.Size = Vector3.new(1, 2.5, 1)
  39. Part1.BottomSurface = Enum.SurfaceType.Smooth
  40. Part1.TopSurface = Enum.SurfaceType.Smooth
  41. SpecialMesh2.Parent = Part1
  42. SpecialMesh2.MeshId = "rbxassetid://445285256"
  43. SpecialMesh2.Scale = Vector3.new(0.150000006, 0.150000006, 0.150000006)
  44. SpecialMesh2.TextureId = "rbxassetid://445285268"
  45. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  46. Sound3.Name = "Blue"
  47. Sound3.Parent = Part1
  48. Sound3.SoundId = "rbxassetid://182981554"
  49. Sound4.Name = "Orange"
  50. Sound4.Parent = Part1
  51. Sound4.SoundId = "rbxassetid://142774034"
  52. Sound5.Name = "Invalid"
  53. Sound5.Parent = Part1
  54. Sound5.SoundId = "rbxassetid://182981577"
  55. Weld6.Parent = Part1
  56. Weld6.C0 = CFrame.new(0.196903229, -0.78666687, 0.0808101892, 1, 0, 0, 0, 0, -1, 0, 1, 0)
  57. Weld6.Part0 = Part1
  58. Weld6.Part1 = Part10
  59. Weld6.part1 = Part10
  60. LocalScript7.Name = "portallocal"
  61. LocalScript7.Parent = Tool0
  62. table.insert(cors,sandbox(LocalScript7,function()
  63. --By Rufus14
  64. local owner
  65. local character
  66. local rootpart
  67. local charhum
  68. mouse = game:GetService("Players").LocalPlayer:GetMouse()
  69. equipped = false
  70. canshoot = true
  71. grabbingwho = nil
  72. runservice = game:GetService("RunService")
  73. tool = script.Parent
  74. handle = tool.Handle
  75. remote = tool:WaitForChild("portal")
  76. bluesound = handle.Blue
  77. orangesound = handle.Orange
  78. invalid = handle.Invalid
  79.  
  80. zoffset = 0
  81. yoffset = 0
  82. xoffset = 0
  83. xrotoffset = 0
  84. yrotoffset = 0
  85. zrotoffset = 0
  86. xrotoffsetportal = 0
  87. yrotoffsetportal = 0
  88. zrotoffsetportal = 0
  89.  
  90. tool.Unequipped:connect(function()
  91. equipped = false
  92. charhum.AutoRotate = true
  93. if character["Right Arm"]:findFirstChild("RightGriplocal") then
  94. character["Right Arm"]:findFirstChild("RightGriplocal"):destroy()
  95. end
  96. if character.Torso:findFirstChild("LeftArmWeldportallocal") then
  97. character.Torso:findFirstChild("LeftArmWeldportallocal"):destroy()
  98. end
  99. if character.Torso:findFirstChild("RightArmWeldportallocal") then
  100. character.Torso:findFirstChild("RightArmWeldportallocal"):destroy()
  101. end
  102. if character.Torso:findFirstChild("HeadWeldportallocal") then
  103. character.Torso:findFirstChild("HeadWeldportallocal"):destroy()
  104. end
  105. if character:findFirstChild("HumanoidRootPart") then
  106. if character.HumanoidRootPart:findFirstChild("HumanoidRootPartWeldportallocal") then
  107. character.HumanoidRootPart:findFirstChild("HumanoidRootPartWeldportallocal"):destroy()
  108. end
  109. end
  110. end)
  111.  
  112. orangeshot = false
  113.  
  114. mouse.KeyDown:connect(function(key)
  115. if not equipped then return end
  116. key = key:lower()
  117. if key == "r" then
  118. remote:FireServer("closeportals")
  119. for i = 1,20 do
  120. yrotoffsetportal = math.sin(i/2)/8
  121. runservice.RenderStepped:wait()
  122. end
  123. yrotoffsetportal = 0
  124. elseif key == "e" then
  125. if grabbingwho == nil then
  126. local ray = Ray.new(character.Head.Position, character.Head.CFrame.lookVector*7)
  127. local hitray, hitposition = workspace:FindPartOnRayWithIgnoreList(ray, {character})
  128. if hitray then
  129. if not hitray.Anchored then
  130. grabbingwho = hitray
  131. canshoot = false
  132. remote:FireServer("grab", hitray)
  133. coroutine.wrap(function()
  134. while runservice.RenderStepped:wait() do
  135. if grabbingwho ~= nil then
  136. grabbingwho.Velocity = Vector3.new()
  137. grabbingwho.CFrame = grabbingwho.CFrame:lerp(character.Head.CFrame * CFrame.new(0,0,-7), 0.1)
  138. end
  139. end
  140. end)()
  141. end
  142. end
  143. else
  144. grabbingwho = nil
  145. remote:FireServer("grab")
  146. for i = 1,20 do
  147. yrotoffsetportal = math.sin(i/2)/8
  148. runservice.RenderStepped:wait()
  149. end
  150. yrotoffsetportal = 0
  151. canshoot = true
  152. end
  153. end
  154. end)
  155.  
  156. mouse.Button1Down:connect(function()
  157. if equipped and canshoot then
  158. remote:FireServer("shootblue", handle.CFrame, mouse.Hit)
  159. for i = 1,10 do
  160. zoffset = math.cos(i/12)/1.5
  161. xrotoffset = math.cos(i/12)/5
  162. runservice.RenderStepped:wait()
  163. end
  164. xrotoffset = 0
  165. zoffset = 0
  166. end
  167. end)
  168. mouse.Button2Down:connect(function()
  169. orangeshot = true
  170. coroutine.wrap(function()
  171. if orangeshot then
  172. wait(0.1)
  173. orangeshot = false
  174. end
  175. end)()
  176. end)
  177. mouse.Button2Up:connect(function()
  178. if equipped and canshoot then
  179. if orangeshot then
  180. remote:FireServer("shootorange", handle.CFrame, mouse.Hit)
  181. for i = 1,10 do
  182. zoffset = math.cos(i/12)/1.5
  183. xrotoffset = math.cos(i/12)/5
  184. runservice.RenderStepped:wait()
  185. end
  186. xrotoffset = 0
  187. zoffset = 0
  188. end
  189. end
  190. end)
  191.  
  192. tool.Equipped:connect(function()
  193. equipped = true
  194. owner = game:GetService("Players").LocalPlayer
  195. character = owner.Character
  196. charhum = character:findFirstChildOfClass("Humanoid")
  197. charhum.AutoRotate = false
  198. rootpart = character.HumanoidRootPart
  199. mouse = owner:GetMouse()
  200. character["Right Arm"]:WaitForChild("RightGrip")
  201. local fakegrip = Instance.new("Weld", character["Right Arm"])
  202. fakegrip.Part0 = character["Right Arm"]
  203. fakegrip.Part1 = handle
  204. fakegrip.Name = "RightGriplocal"
  205. fakegrip.C0 = CFrame.new(0.0172424316, -1.10172808, -0.631057739, 0.939694643, 0.342014611, 1.5361735e-06, 0.336815238, -0.925408483, -0.173644245, -0.0593881048, 0.163174912, -0.984808147)
  206. local rightarm = Instance.new("Weld", character.Torso)
  207. rightarm.Part0 = character.Torso
  208. rightarm.Part1 = character["Right Arm"]
  209. rightarm.C0 = CFrame.new(1.5,0,0)
  210. rightarm.Name = "RightArmWeldportallocal"
  211. local leftarm = Instance.new("Weld", character.Torso)
  212. leftarm.Part0 = character.Torso
  213. leftarm.Part1 = character["Left Arm"]
  214. leftarm.C0 = CFrame.new(-1.5,0,0)
  215. leftarm.Name = "LeftArmWeldportallocal"
  216. local head = Instance.new("Weld", character.Torso)
  217. head.Part0 = character.Torso
  218. head.Part1 = character.Head
  219. head.C0 = CFrame.new(0,1.5,0)
  220. head.Name = "HeadWeldportallocal"
  221. local humanoidrootpart = Instance.new("Weld", rootpart)
  222. humanoidrootpart.Part0 = rootpart
  223. humanoidrootpart.Part1 = character.Torso
  224. humanoidrootpart.Name = "HumanoidRootPartWeldportallocal"
  225. coroutine.wrap(function()
  226. while wait() and equipped do --send c0
  227. remote:FireServer("updatec0", "RightGrip", fakegrip.C0)
  228. remote:FireServer("updatec0", "HeadWeldportal", head.C0)
  229. remote:FireServer("updatec0", "HumanoidRootPartWeldportal", humanoidrootpart.C0)
  230. remote:FireServer("updatec0", "LeftArmWeldportal", leftarm.C0)
  231. remote:FireServer("updatec0", "RightArmWeldportal", rightarm.C0)
  232. end
  233. end)()
  234. coroutine.wrap(function()
  235. while runservice.RenderStepped:wait() and equipped do
  236. if rootpart.Velocity.x >= 2 or rootpart.Velocity.x <= -2 or rootpart.Velocity.z >= 2 or rootpart.Velocity.z <= -2 then
  237. xoffset = math.sin(tick()*5)/10
  238. yoffset = math.sin(tick()*10)/10
  239. elseif rootpart.Velocity.x <= 2 or rootpart.Velocity.x >= -2 or rootpart.Velocity.z <= 2 or rootpart.Velocity.z >= -2 then
  240. xoffset = 0
  241. yoffset = math.sin(tick())/20
  242. --print("standing")
  243. end
  244. end
  245. end)()
  246. coroutine.wrap(function()
  247. while runservice.RenderStepped:wait() and equipped do
  248. character["Left Arm"].LocalTransparencyModifier = 0
  249. character["Right Arm"].LocalTransparencyModifier = 0
  250. for q,w in pairs(character.Head:GetDescendants()) do
  251. if w.Name == "NoPortal" or w.Name == "BluePortal" or w.Name == "OrangePortal" or w.Name == "pellet" then
  252. w.LocalTransparencyModifier = 0
  253. end
  254. end
  255. if (workspace.CurrentCamera.CFrame.p - character.Head.CFrame.p).magnitude <= 1.5 then
  256. charhum.CameraOffset = Vector3.new(0,0.5,0)
  257. else
  258. charhum.CameraOffset = Vector3.new(0,0,0)
  259. end
  260. local absvel = rootpart.CFrame:vectorToObjectSpace(rootpart.Velocity)
  261. humanoidrootpart.C0 = humanoidrootpart.C0:lerp(CFrame.fromEulerAnglesXYZ(absvel.z/120,0,-absvel.x/120),0.1)
  262. if not charhum.PlatformStand then
  263. rootpart.CFrame = rootpart.CFrame:lerp(CFrame.new(rootpart.Position, Vector3.new(mouse.Hit.p.x,rootpart.Position.y,mouse.Hit.p.z)),0.2)
  264. else
  265. charhum.PlatformStand = false
  266. end
  267. fakegrip.C0 = fakegrip.C0:lerp(CFrame.new(0.0172424316, -1.10172808, -0.631057739, 0.939694643, 0.342014611, 1.5361735e-06, 0.336815238, -0.925408483, -0.173644245, -0.0593881048, 0.163174912, -0.984808147) * CFrame.fromEulerAnglesXYZ(xrotoffsetportal,yrotoffsetportal,zrotoffsetportal),0.2)
  268. head.C0 = head.C0:lerp(CFrame.new(0,1,0) * CFrame.fromEulerAnglesXYZ(((mouse.Hit.p-mouse.Origin.p).unit.y),0,0) * CFrame.new(0,0.5,0),0.2)
  269. leftarm.C0 = leftarm.C0:lerp(CFrame.new(-0.3+xoffset,-0.3+yoffset,-0.5+zoffset) * CFrame.fromEulerAnglesXYZ((((mouse.Hit.p-mouse.Origin.p).unit.y)+math.pi/2)+xrotoffset,yrotoffset,math.rad(30)+zrotoffset) * CFrame.new(0,-1,-0.5),0.2)
  270. rightarm.C0 = rightarm.C0:lerp(CFrame.new(1+xoffset,0+yoffset,-0.3+zoffset) * CFrame.fromEulerAnglesXYZ((((mouse.Hit.p-mouse.Origin.p).unit.y)+math.pi/2)+xrotoffset,yrotoffset,math.rad(-20)+zrotoffset) * CFrame.new(0,-0.5,-0.5),0.2)
  271. end
  272. character["Left Arm"].LocalTransparencyModifier = 0
  273. character["Right Arm"].LocalTransparencyModifier = 0
  274. charhum.CameraOffset = Vector3.new(0,0,0)
  275. end)()
  276. end)
  277. end))
  278. RemoteEvent8.Name = "portal"
  279. RemoteEvent8.Parent = Tool0
  280. Script9.Name = "portalserver"
  281. Script9.Parent = Tool0
  282. table.insert(cors,sandbox(Script9,function()
  283. --By Rufus14
  284. local owner
  285. local character
  286. equipped = false
  287. canshoot = true
  288. grabbing = false
  289. tool = script.Parent
  290. handle = tool.Handle
  291. remote = tool.portal
  292. runservice = game:GetService("RunService")
  293. bluesound = handle.Blue
  294. orangesound = handle.Orange
  295. invalid = handle.Invalid
  296. light = tool.Light
  297.  
  298. illegalmaterial = {Enum.Material.WoodPlanks, Enum.Material.CorrodedMetal, Enum.Material.Grass, Enum.Material.Brick, Enum.Material.Cobblestone, Enum.Material.ForceField, Enum.Material.Fabric}
  299.  
  300. tool.Equipped:connect(function()
  301. equipped = true
  302. owner = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)
  303. character = owner.Character
  304. local rightarm = Instance.new("Weld", character.Torso)
  305. rightarm.Part0 = character.Torso
  306. rightarm.Part1 = character["Right Arm"]
  307. rightarm.C0 = CFrame.new(1.5,0,0)
  308. rightarm.Name = "RightArmWeldportal"
  309. local leftarm = Instance.new("Weld", character.Torso)
  310. leftarm.Part0 = character.Torso
  311. leftarm.Part1 = character["Left Arm"]
  312. leftarm.C0 = CFrame.new(-1.5,0,0)
  313. leftarm.Name = "LeftArmWeldportal"
  314. local head = Instance.new("Weld", character.Torso)
  315. head.Part0 = character.Torso
  316. head.Part1 = character.Head
  317. head.C0 = CFrame.new(0,1.5,0)
  318. head.Name = "HeadWeldportal"
  319. local humanoidrootpart = Instance.new("Weld", character.HumanoidRootPart)
  320. humanoidrootpart.Part0 = character.HumanoidRootPart
  321. humanoidrootpart.Part1 = character.Torso
  322. humanoidrootpart.Name = "HumanoidRootPartWeldportal"
  323. end)
  324. tool.Unequipped:connect(function()
  325. equipped = false
  326. if character.Torso:findFirstChild("LeftArmWeldportal") then
  327. character.Torso:findFirstChild("LeftArmWeldportal"):destroy()
  328. end
  329. if character.Torso:findFirstChild("RightArmWeldportal") then
  330. character.Torso:findFirstChild("RightArmWeldportal"):destroy()
  331. end
  332. if character.Torso:findFirstChild("HeadWeldportal") then
  333. character.Torso:findFirstChild("HeadWeldportal"):destroy()
  334. end
  335. if character:findFirstChild("HumanoidRootPart") then
  336. if character.HumanoidRootPart:findFirstChild("HumanoidRootPartWeldportal") then
  337. character.HumanoidRootPart:findFirstChild("HumanoidRootPartWeldportal"):destroy()
  338. end
  339. end
  340. end)
  341.  
  342. remote.OnServerEvent:connect(function(plr, what, value, value2)
  343. if plr ~= owner then return end
  344. --
  345. if what == "updatec0" then
  346. for i,v in pairs(character:GetDescendants()) do
  347. if v.Name == value then
  348. v.C0 = value2
  349. end
  350. end
  351. elseif what == "grab" then
  352. if not grabbing then
  353. grabbing = true
  354. light.Transparency = 0
  355. light.BrickColor = BrickColor.new("Institutional white")
  356. for q,w in pairs(value:GetDescendants()) do
  357. if w.ClassName == "Part" or w.ClassName == "MeshPart" then
  358. w.Anchored = false
  359. end
  360. end
  361. value:SetNetworkOwner(owner)
  362. local wentthh = Instance.new("BoolValue", value)
  363. wentthh.Name = "wentthroughportal"
  364. coroutine.wrap(function()
  365. while grabbing do runservice.Stepped:wait() end
  366. wentthh:destroy()
  367. value:SetNetworkOwner(nil)
  368. end)()
  369. else
  370. light.Transparency = 1
  371. grabbing = false
  372. end
  373. elseif what == "closeportals" then
  374. light.Transparency = 1
  375. if character.Head:findFirstChild("BluePortal") then
  376. local blu = character.Head:findFirstChild("BluePortal")
  377. local soundpart = Instance.new("UnionOperation", character.Head)
  378. soundpart.Transparency = 1
  379. soundpart.CanCollide = false
  380. soundpart.CFrame = blu.CFrame
  381. soundpart.Anchored = true
  382. local soundclose = Instance.new("Sound", soundpart)
  383. soundclose.SoundId = "rbxassetid://182981587"
  384. soundclose.Volume = 1
  385. soundclose:Play()
  386. game.Debris:AddItem(soundpart, soundclose.TimeLength)
  387. coroutine.wrap(function()
  388. for i = 1,10 do
  389. blu.Size = blu.Size - Vector3.new(0.35,0.5,0)
  390. runservice.Stepped:wait()
  391. end
  392. blu:destroy()
  393. end)()
  394. end
  395. if character.Head:findFirstChild("OrangePortal") then
  396. local orang = character.Head:findFirstChild("OrangePortal")
  397. local soundpart = Instance.new("UnionOperation", character.Head)
  398. soundpart.Transparency = 1
  399. soundpart.CanCollide = false
  400. soundpart.CFrame = orang.CFrame
  401. soundpart.Anchored = true
  402. local soundclose = Instance.new("Sound", soundpart)
  403. soundclose.SoundId = "rbxassetid://182981587"
  404. soundclose.Volume = 1
  405. soundclose:Play()
  406. game.Debris:AddItem(soundpart, soundclose.TimeLength)
  407. coroutine.wrap(function()
  408. for i = 1,10 do
  409. orang.Size = orang.Size - Vector3.new(0.35,0.5,0)
  410. runservice.Stepped:wait()
  411. end
  412. orang:destroy()
  413. end)()
  414. end
  415. elseif what == "shootblue" then
  416. bluesound.PlaybackSpeed = 1+(math.random(-20,20)/120)
  417. bluesound:Play()
  418. light.Transparency = 0
  419. light.BrickColor = BrickColor.new("Toothpaste")
  420. local pellet = Instance.new("Part", character.Head)
  421. pellet.Size = Vector3.new(0.7,0.7,1.7)
  422. pellet.Name = "pellet"
  423. pellet.Material = "Neon"
  424. pellet.BrickColor = BrickColor.new("Toothpaste")
  425. pellet.CFrame = value * CFrame.new(0,2,0)
  426. pellet.CFrame = CFrame.new(pellet.Position, value2.p)
  427. pellet.CanCollide = false
  428. pellet.Anchored = true
  429. Instance.new("PointLight", pellet).Brightness = 4
  430. local mesh = Instance.new("SpecialMesh", pellet)
  431. mesh.MeshType = "Sphere"
  432. local hitwall = false
  433. local ignorelist = {}
  434. for i,v in pairs(workspace:GetDescendants()) do
  435. if v.ClassName == "Model" then
  436. if v:findFirstChildOfClass("Humanoid") then
  437. table.insert(ignorelist, v)
  438. end
  439. end
  440. end
  441. local function awman()
  442. invalid:Play()
  443. invalid.PlaybackSpeed = 1+(math.random(-20,20)/120)
  444. local boom = Instance.new("Part", character.Head)
  445. boom.CanCollide = false
  446. boom.Anchored = false
  447. boom.Shape = "Ball"
  448. boom.Name = "NoPortal"
  449. boom.Anchored = true
  450. boom.Material = "Neon"
  451. boom.CFrame = pellet.CFrame
  452. coroutine.wrap(function()
  453. for i = 1,10 do
  454. boom.Size = boom.Size + Vector3.new(0.15,0.15,0.15)
  455. boom.Transparency = boom.Transparency + 0.1
  456. runservice.Stepped:wait()
  457. end
  458. boom:Destroy()
  459. end)()
  460. for i = 1,math.random(4,10) do
  461. local laser = Instance.new("UnionOperation", character.Head)
  462. Instance.new("BlockMesh", laser)
  463. laser.BrickColor = BrickColor.new("Toothpaste")
  464. laser.Anchored = true
  465. laser.Material = "Neon"
  466. laser.Name = "NoPortal"
  467. laser.Size = Vector3.new(0.1,0.1,1)
  468. laser.CanCollide = false
  469. laser.CFrame = pellet.CFrame
  470. laser.CFrame = laser.CFrame * CFrame.fromEulerAnglesXYZ(math.random(-10,10)/1.5,math.random(-10,10)/1.5,math.random(-10,10)/1.5)
  471. coroutine.wrap(function()
  472. for i = 1,20 do
  473. laser.Transparency = laser.Transparency + 0.05
  474. laser.CFrame = laser.CFrame * CFrame.new(0,0,-0.1)
  475. runservice.Stepped:wait()
  476. end
  477. laser:destroy()
  478. end)()
  479. end
  480. pellet:destroy()
  481. end
  482. coroutine.wrap(function()
  483. local threshold = 0
  484. while runservice.Stepped:wait() and not hitwall do
  485. local ray = Ray.new(pellet.Position, pellet.CFrame.lookVector*8)
  486. local rayhit, raypos, raysurface = workspace:FindPartOnRayWithIgnoreList(ray, ignorelist)
  487. if rayhit then
  488. if rayhit.Name ~= "NoPortal" then
  489. hitwall = true
  490. if rayhit.Name == "OrangePortal" then
  491. awman()
  492. return
  493. end
  494. for i,v in pairs(illegalmaterial) do
  495. if v == rayhit.Material then
  496. awman()
  497. return
  498. end
  499. end
  500. if character.Head:findFirstChild("BluePortal") then
  501. character.Head.BluePortal:destroy()
  502. end
  503. local portal = Instance.new("UnionOperation", character.Head)
  504. local mesh = Instance.new("SpecialMesh", portal)
  505. mesh.MeshType = "Sphere"
  506. portal.Size = Vector3.new(1,1,0.4)
  507. portal.Name = "BluePortal"
  508. portal.BrickColor = BrickColor.new("Toothpaste")
  509. portal.Material = "Neon"
  510. portal.CanCollide = false
  511. portal.Anchored = true
  512. portal.CFrame = CFrame.new(raypos, raypos-raysurface)
  513. coroutine.wrap(function()
  514. for i = 1,10 do
  515. portal.Size = portal.Size + Vector3.new(0.35,0.5,0)
  516. runservice.Stepped:wait()
  517. end
  518. end)()
  519. local portalopen = Instance.new("Sound", portal)
  520. portalopen.SoundId = "rbxassetid://171399373"
  521. portalopen.Volume = 1.5
  522. portalopen.PlaybackSpeed = 1+(math.random(-20,20)/120)
  523. portalopen:Play()
  524. local portalidle = Instance.new("Sound", portal)
  525. portalidle.SoundId = "rbxassetid://148894502"
  526. portalidle.Volume = 0.25
  527. portalidle:Play()
  528. portalidle.Looped = true
  529. local gothroughsound = Instance.new("Sound", portal)
  530. gothroughsound.Volume = 3
  531. game.Debris:AddItem(portalopen, portalopen.TimeLength)
  532. portal.Touched:connect(function(part)
  533. if part.Anchored then return end
  534. gothroughsound.PlaybackSpeed = 1+(math.random(-20,20)/120)
  535. if part.Parent.ClassName == "Accessory" or part.Parent.ClassName == "Hat" or part.Parent.ClassName == "Tool" then
  536. if part.Parent.Parent ~= workspace then
  537. --print("ignored hat on player")
  538. return
  539. end
  540. end
  541. if character.Head:findFirstChild("OrangePortal") then
  542. local humus = part.Parent:findFirstChildOfClass("Humanoid")
  543. if humus then
  544. local head = part.Parent:findFirstChild("Head")
  545. if head then
  546. local wentthrough = part.Parent:findFirstChild("wentthroughportal")
  547. --[[if wentthrough then
  548. print("returned from head tp")
  549. return
  550. end--]]
  551. if not wentthrough then
  552. local wentth = Instance.new("BoolValue", part.Parent)
  553. wentth.Name = "wentthroughportal"
  554. game.Debris:AddItem(wentth, 0.4)
  555. local headvelocity = head.Velocity
  556. if headvelocity.y < -50 or headvelocity.y > 50 or headvelocity.z < -50 or headvelocity.z > 50 or headvelocity.x < -50 or headvelocity.x > 50 then
  557. gothroughsound.SoundId = "rbxassetid://2769872789"
  558. else
  559. gothroughsound.SoundId = "rbxassetid://232806289"
  560. end
  561. gothroughsound:Play()
  562. head.CFrame = character.Head.OrangePortal.CFrame * CFrame.new(0,2,4)
  563. local px,py,pz = character.Head.OrangePortal.CFrame:toEulerAnglesXYZ()
  564. head.CFrame = CFrame.new(head.Position) * CFrame.fromEulerAnglesXYZ(0,py,0)
  565. local pushv = Instance.new("BodyVelocity", head)
  566. pushv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  567. pushv.Velocity = character.Head.OrangePortal.CFrame.lookVector * (-15 + headvelocity.y/1.2)
  568. humus:ChangeState(Enum.HumanoidStateType.GettingUp)
  569. game.Debris:AddItem(pushv, 0.2)
  570. end
  571. else
  572. local wentthrough = part:findFirstChild("wentthroughportal")
  573. --[[if wentthrough then
  574. print("returned from humanoid part tp")
  575. return
  576. end--]]
  577. if not wentthrough then
  578. local wentth = Instance.new("BoolValue", part)
  579. wentth.Name = "wentthroughportal"
  580. game.Debris:AddItem(wentth, 0.4)
  581. local partvelocity = part.Velocity
  582. if partvelocity.y < -50 or partvelocity.y > 50 or partvelocity.z < -50 or partvelocity.z > 50 or partvelocity.x < -50 or partvelocity.x > 50 then
  583. gothroughsound.SoundId = "rbxassetid://2769872789"
  584. else
  585. gothroughsound.SoundId = "rbxassetid://232806289"
  586. end
  587. gothroughsound:Play()
  588. part.CFrame = character.Head.OrangePortal.CFrame * CFrame.new(0,2,4)
  589. local pushv = Instance.new("BodyVelocity", part)
  590. pushv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  591. pushv.Velocity = character.Head.OrangePortal.CFrame.lookVector * (-15 + partvelocity.y/1.2)
  592. game.Debris:AddItem(pushv, 0.2)
  593. end
  594. end
  595. else
  596. local wentthrough = part:findFirstChild("wentthroughportal")
  597. --[[if wentthrough then
  598. print("returned from part tp")
  599. return
  600. end--]]
  601. if not wentthrough then
  602. local wentth = Instance.new("BoolValue", part)
  603. wentth.Name = "wentthroughportal"
  604. game.Debris:AddItem(wentth, 0.4)
  605. local partvelocity = part.Velocity
  606. if partvelocity.y < -50 or partvelocity.y > 50 or partvelocity.z < -50 or partvelocity.z > 50 or partvelocity.x < -50 or partvelocity.x > 50 then
  607. gothroughsound.SoundId = "rbxassetid://2769872789"
  608. else
  609. gothroughsound.SoundId = "rbxassetid://232806289"
  610. end
  611. gothroughsound:Play()
  612. part.CFrame = character.Head.OrangePortal.CFrame * CFrame.new(0,2,4)
  613. local pushv = Instance.new("BodyVelocity", part)
  614. pushv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  615. pushv.Velocity = character.Head.OrangePortal.CFrame.lookVector * (-15 + partvelocity.y/1.2)
  616. game.Debris:AddItem(pushv, 0.2)
  617. end
  618. end
  619. end
  620. end)
  621. else
  622. awman()
  623. end
  624. end
  625. pellet.CFrame = pellet.CFrame * CFrame.new(0,0,-8)
  626. threshold = threshold + 1
  627. if threshold == 200 then
  628. pellet:destroy()
  629. break
  630. end
  631. end
  632. pellet:destroy()
  633. end)()
  634. elseif what == "shootorange" then
  635. orangesound.PlaybackSpeed = 1+(math.random(-20,20)/120)
  636. orangesound:Play()
  637. light.Transparency = 0
  638. light.BrickColor = BrickColor.new("Deep orange")
  639. local pellet = Instance.new("Part", character.Head)
  640. pellet.Size = Vector3.new(0.7,0.7,1.7)
  641. pellet.Material = "Neon"
  642. pellet.Name = "pellet"
  643. pellet.BrickColor = BrickColor.new("Deep orange")
  644. pellet.CFrame = value * CFrame.new(0,2,0)
  645. pellet.CFrame = CFrame.new(pellet.Position, value2.p)
  646. pellet.CanCollide = false
  647. pellet.Anchored = true
  648. Instance.new("PointLight", pellet).Brightness = 4
  649. local mesh = Instance.new("SpecialMesh", pellet)
  650. mesh.MeshType = "Sphere"
  651. local hitwall = false
  652. local ignorelist = {}
  653. for i,v in pairs(workspace:GetDescendants()) do
  654. if v.ClassName == "Model" then
  655. if v:findFirstChildOfClass("Humanoid") then
  656. table.insert(ignorelist, v)
  657. end
  658. end
  659. end
  660. local function awman()
  661. invalid:Play()
  662. invalid.PlaybackSpeed = 1+(math.random(-20,20)/120)
  663. local boom = Instance.new("Part", character.Head)
  664. boom.CanCollide = false
  665. boom.Anchored = true
  666. boom.Shape = "Ball"
  667. boom.Name = "NoPortal"
  668. boom.Material = "Neon"
  669. boom.CFrame = pellet.CFrame
  670. coroutine.wrap(function()
  671. for i = 1,10 do
  672. boom.Size = boom.Size + Vector3.new(0.15,0.15,0.15)
  673. boom.Transparency = boom.Transparency + 0.1
  674. runservice.Stepped:wait()
  675. end
  676. boom:Destroy()
  677. end)()
  678. for i = 1,math.random(4,10) do
  679. local laser = Instance.new("UnionOperation", character.Head)
  680. Instance.new("BlockMesh", laser)
  681. laser.BrickColor = BrickColor.new("Deep orange")
  682. laser.Size = Vector3.new(0.1,0.1,1)
  683. laser.Anchored = true
  684. laser.Material = "Neon"
  685. laser.Name = "NoPortal"
  686. laser.CanCollide = false
  687. laser.CFrame = pellet.CFrame
  688. laser.CFrame = laser.CFrame * CFrame.fromEulerAnglesXYZ(math.random(-10,10)/1.5,math.random(-10,10)/1.5,math.random(-10,10)/1.5)
  689. coroutine.wrap(function()
  690. for i = 1,20 do
  691. laser.Transparency = laser.Transparency + 0.05
  692. laser.CFrame = laser.CFrame * CFrame.new(0,0,-0.1)
  693. runservice.Stepped:wait()
  694. end
  695. laser:destroy()
  696. end)()
  697. end
  698. pellet:destroy()
  699. end
  700. coroutine.wrap(function()
  701. local threshold = 0
  702. while runservice.Stepped:wait() and not hitwall do
  703. local ray = Ray.new(pellet.Position, pellet.CFrame.lookVector*8)
  704. local rayhit, raypos, raysurface = workspace:FindPartOnRayWithIgnoreList(ray, ignorelist)
  705. if rayhit then
  706. if rayhit.Name ~= "NoPortal" then
  707. hitwall = true
  708. if rayhit.Name == "BluePortal" then
  709. awman()
  710. return
  711. end
  712. for i,v in pairs(illegalmaterial) do
  713. if v == rayhit.Material then
  714. awman()
  715. return
  716. end
  717. end
  718. if character.Head:findFirstChild("OrangePortal") then
  719. character.Head.OrangePortal:destroy()
  720. end
  721. local portal = Instance.new("UnionOperation", character.Head)
  722. local mesh = Instance.new("SpecialMesh", portal)
  723. mesh.MeshType = "Sphere"
  724. portal.Size = Vector3.new(1,1,0.4)
  725. portal.Name = "OrangePortal"
  726. portal.BrickColor = BrickColor.new("Deep orange")
  727. portal.Material = "Neon"
  728. portal.CanCollide = false
  729. portal.Anchored = true
  730. portal.CFrame = CFrame.new(raypos, raypos-raysurface)
  731. coroutine.wrap(function()
  732. for i = 1,10 do
  733. portal.Size = portal.Size + Vector3.new(0.35,0.5,0)
  734. runservice.Stepped:wait()
  735. end
  736. end)()
  737. local portalopen = Instance.new("Sound", portal)
  738. portalopen.SoundId = "rbxassetid://171399373"
  739. portalopen.Volume = 1.5
  740. portalopen.PlaybackSpeed = 1+(math.random(-20,20)/120)
  741. portalopen:Play()
  742. local portalidle = Instance.new("Sound", portal)
  743. portalidle.SoundId = "rbxassetid://148894502"
  744. portalidle.Volume = 0.25
  745. portalidle:Play()
  746. portalidle.Looped = true
  747. local gothroughsound = Instance.new("Sound", portal)
  748. gothroughsound.Volume = 1.5
  749. game.Debris:AddItem(portalopen, portalopen.TimeLength)
  750. portal.Touched:connect(function(part)
  751. if part.Anchored then return end
  752. gothroughsound.PlaybackSpeed = 1+(math.random(-20,20)/120)
  753. if part.Parent.ClassName == "Accessory" or part.Parent.ClassName == "Hat" or part.Parent.ClassName == "Tool" then
  754. if part.Parent.Parent ~= workspace then
  755. --print("ignored hat on player")
  756. return
  757. end
  758. end
  759. if character.Head:findFirstChild("BluePortal") then
  760. local humus = part.Parent:findFirstChildOfClass("Humanoid")
  761. if humus then
  762. local head = part.Parent:findFirstChild("Head")
  763. if head then
  764. local wentthrough = part.Parent:findFirstChild("wentthroughportal")
  765. --[[if wentthrough then
  766. print("returned from head tp")
  767. return
  768. end--]]
  769. if not wentthrough then
  770. local wentth = Instance.new("BoolValue", part.Parent)
  771. wentth.Name = "wentthroughportal"
  772. game.Debris:AddItem(wentth, 0.4)
  773. local headvelocity = head.Velocity
  774. if headvelocity.y < -50 or headvelocity.y > 50 or headvelocity.z < -50 or headvelocity.z > 50 or headvelocity.x < -50 or headvelocity.x > 50 then
  775. gothroughsound.SoundId = "rbxassetid://2769872789"
  776. else
  777. gothroughsound.SoundId = "rbxassetid://232806289"
  778. end
  779. gothroughsound:Play()
  780. head.CFrame = character.Head.BluePortal.CFrame * CFrame.new(0,2,4)
  781. local px,py,pz = character.Head.BluePortal.CFrame:toEulerAnglesXYZ()
  782. head.CFrame = CFrame.new(head.Position) * CFrame.fromEulerAnglesXYZ(0,py,0)
  783. local pushv = Instance.new("BodyVelocity", head)
  784. pushv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  785. pushv.Velocity = character.Head.BluePortal.CFrame.lookVector * (-15 + headvelocity.y/1.2)
  786. humus:ChangeState(Enum.HumanoidStateType.GettingUp)
  787. game.Debris:AddItem(pushv, 0.2)
  788. end
  789. else
  790. local wentthrough = part:findFirstChild("wentthroughportal")
  791. --[[if wentthrough then
  792. print("returned from humanoid part tp")
  793. return
  794. end--]]
  795. if not wentthrough then
  796. local wentth = Instance.new("BoolValue", part)
  797. wentth.Name = "wentthroughportal"
  798. game.Debris:AddItem(wentth, 0.4)
  799. local partvelocity = part.Velocity
  800. if partvelocity.y < -50 or partvelocity.y > 50 or partvelocity.z < -50 or partvelocity.z > 50 or partvelocity.x < -50 or partvelocity.x > 50 then
  801. gothroughsound.SoundId = "rbxassetid://2769872789"
  802. else
  803. gothroughsound.SoundId = "rbxassetid://232806289"
  804. end
  805. gothroughsound:Play()
  806. part.CFrame = character.Head.BluePortal.CFrame * CFrame.new(0,2,4)
  807. local pushv = Instance.new("BodyVelocity", part)
  808. pushv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  809. pushv.Velocity = character.Head.BluePortal.CFrame.lookVector * (-15 + partvelocity.y/1.2)
  810. game.Debris:AddItem(pushv, 0.2)
  811. end
  812. end
  813. else
  814. local wentthrough = part:findFirstChild("wentthroughportal")
  815. --[[if wentthrough then
  816. print("returned from part tp")
  817. return
  818. end--]]
  819. if not wentthrough then
  820. local wentth = Instance.new("BoolValue", part)
  821. wentth.Name = "wentthroughportal"
  822. game.Debris:AddItem(wentth, 0.4)
  823. local partvelocity = part.Velocity
  824. if partvelocity.y < -50 or partvelocity.y > 50 or partvelocity.z < -50 or partvelocity.z > 50 or partvelocity.x < -50 or partvelocity.x > 50 then
  825. gothroughsound.SoundId = "rbxassetid://2769872789"
  826. else
  827. gothroughsound.SoundId = "rbxassetid://232806289"
  828. end
  829. gothroughsound:Play()
  830. part.CFrame = character.Head.BluePortal.CFrame * CFrame.new(0,2,4)
  831. local pushv = Instance.new("BodyVelocity", part)
  832. pushv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  833. pushv.Velocity = character.Head.BluePortal.CFrame.lookVector * (-15 + partvelocity.y/1.2)
  834. game.Debris:AddItem(pushv, 0.2)
  835. end
  836. end
  837. end
  838. end)
  839. else
  840. awman()
  841. end
  842. end
  843. pellet.CFrame = pellet.CFrame * CFrame.new(0,0,-8)
  844. threshold = threshold + 1
  845. if threshold == 200 then
  846. pellet:destroy()
  847. break
  848. end
  849. end
  850. pellet:destroy()
  851. end)()
  852. end
  853. end)
  854. end))
  855. Part10.Name = "Light"
  856. Part10.Parent = Tool0
  857. Part10.CFrame = CFrame.new(6.01353025, 0.580815196, -2.69899321, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  858. Part10.Position = Vector3.new(6.01353025, 0.580815196, -2.69899321)
  859. Part10.Color = Color3.new(0, 1, 1)
  860. Part10.Transparency = 1
  861. Part10.Size = Vector3.new(0.230000943, 0.230000943, 0.230000943)
  862. Part10.BottomSurface = Enum.SurfaceType.Smooth
  863. Part10.BrickColor = BrickColor.new("Toothpaste")
  864. Part10.Material = Enum.Material.Neon
  865. Part10.TopSurface = Enum.SurfaceType.Smooth
  866. Part10.brickColor = BrickColor.new("Toothpaste")
  867. Part10.Shape = Enum.PartType.Ball
  868. for i,v in pairs(mas:GetChildren()) do
  869. v.Parent = owner.Character
  870. pcall(function() v:MakeJoints() end)
  871. end
  872. mas:Destroy()
  873. for i,v in pairs(cors) do
  874. spawn(function()
  875. pcall(v)
  876. end)
  877. end
  878.  
Add Comment
Please, Sign In to add comment