Advertisement
Rufus14

Portal Gun

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