Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait(1/30)
- --script.Parent = nil
- local Plrs = game:GetService("Players")
- local RS = game:GetService("RunService")
- local LP = Plrs.LocalPlayer
- local Mouse = LP:GetMouse()
- local Char = LP.Character
- local isRemoving = {}
- local isMoving = {}
- local Debounces = {}
- local isTeleporting = false
- local LastPortalNum = 1
- pcall(function() workspace["Portals"]:Destroy() end)
- local Model = Instance.new("Model")
- Model.Name = "Portals"
- Model.Parent = workspace
- ------------------------------------------------------------------------------------------------------------------------------------------------------
- function removePortal(StringNum)
- if not Model or not Model.Parent then
- Model = Instance.new("Model")
- Model.Name = "Portals"
- Model.Parent = workspace
- end
- if Model:findFirstChild(StringNum) then
- local PortalP = Model[StringNum]
- local PortalPM = PortalP["PortalPM"]
- isRemoving[PortalP] = true
- PortalP.Name = "Removing"
- if PortalPM.Transparency < 1 then
- for i = 0, 90, 3 do
- PortalPM.Transparency = math.max(math.sin(math.rad(i)), PortalPM.Transparency)
- RS.Heartbeat:wait()
- end
- end
- PortalPM:Destroy()
- local PortalPSize = PortalP.Size
- local PortalPCFrame = PortalP.CFrame
- for i = 0, 1, 0.25 do
- PortalP.Size = PortalPSize:lerp(Vector3.new(9, 0.3, 9), i)
- PortalP.CFrame = PortalPCFrame
- RS.Heartbeat:wait()
- end
- PortalPSize = PortalP.Size
- for i = 0, 1, 0.2 do
- PortalP.Size = PortalPSize:lerp(Vector3.new(0, 0.3, 0), i)
- PortalP.CFrame = PortalPCFrame
- RS.Heartbeat:wait()
- end
- PortalP:Destroy()
- isTeleporting = false
- isRemoving[PortalP] = nil
- return true
- end
- return false
- end
- function makePortal(Num, Hit, Target, Surface)
- local StringNum = tostring(Num)
- isMoving[Num] = nil
- LastPortalNum = Num
- local Num2 = 1
- if Num == 1 then
- Num2 = 2
- end
- local StringNum2 = tostring(Num2)
- local TargetAng = Target.CFrame - Target.CFrame.p
- local offsetCFrame = CFrame.new(Hit.p) * TargetAng
- if Surface ~= Enum.NormalId.Top then
- print(Target.Name)
- end
- if Surface == Enum.NormalId.Top then
- offsetCFrame = offsetCFrame
- elseif Surface == Enum.NormalId.Bottom then
- offsetCFrame = offsetCFrame * CFrame.Angles(0, 0, math.rad(180))
- elseif Surface == Enum.NormalId.Front then
- offsetCFrame = offsetCFrame * CFrame.Angles(math.rad(-90), 0, 0)
- elseif Surface == Enum.NormalId.Back then
- offsetCFrame = offsetCFrame * CFrame.Angles(math.rad(90), 0, 0)
- elseif Surface == Enum.NormalId.Left then
- offsetCFrame = offsetCFrame * CFrame.Angles(0, 0, math.rad(90))
- elseif Surface == Enum.NormalId.Right then
- offsetCFrame = offsetCFrame * CFrame.Angles(0, 0, math.rad(-90))
- end
- local PortalP = Instance.new("Part")
- PortalP.Name = StringNum
- PortalP.Material = "Plastic"
- PortalP.FormFactor = "Custom"
- PortalP.Color = Color3.new(0, 0, 0)
- PortalP.Transparency = 0
- PortalP.Anchored = true
- PortalP.CanCollide = true
- PortalP.Locked = true
- PortalP.BottomSurface, PortalP.TopSurface = "Smooth", "Smooth"
- PortalP.Size = Vector3.new(0, 0.3, 0)
- PortalP.CFrame = offsetCFrame * CFrame.new(0, 0.15, 0)
- PortalP.Parent = Model
- local CylMesh = Instance.new("CylinderMesh", PortalP)
- CylMesh.Name = "CylMesh"
- local PortalPM = Instance.new("Part")
- PortalPM.Name = "PortalPM"
- PortalPM.Material = "Plastic"
- PortalPM.FormFactor = "Custom"
- PortalPM.Color = Color3.new(1, 1, 1)
- PortalPM.Transparency = 1
- PortalPM.Anchored = true
- PortalPM.CanCollide = true
- PortalPM.Locked = true
- PortalPM.BottomSurface, PortalPM.TopSurface = "Smooth", "Smooth"
- PortalPM.Size = Vector3.new(5, 0.2, 5)
- PortalPM.CFrame = PortalP.CFrame * CFrame.new(0, 0.15, 0)
- PortalPM.Parent = PortalP
- local CylMesh = Instance.new("CylinderMesh", PortalP)
- CylMesh.Name = "CylMesh"
- local CylMeshM = Instance.new("CylinderMesh", PortalPM)
- CylMeshM.Name = "CylMeshM"
- coroutine.wrap(function()
- while Model.Parent and PortalP.Parent and PortalPM.Parent do
- if isMoving[Num] == nil then
- PortalP.CFrame = offsetCFrame * CFrame.new(0, 0.15, 0)
- PortalPM.CFrame = offsetCFrame * CFrame.new(0, 0.3, 0)
- end
- RS.Heartbeat:wait()
- end
- end)()
- local PortalPSize = PortalP.Size
- for i = 0, 1, 0.1 do
- if isRemoving[PortalP] then
- return
- end
- PortalP.Size = PortalPSize:lerp(Vector3.new(9, 0.3, 9), i)
- PortalP.CFrame = offsetCFrame * CFrame.new(0, 0.15, 0)
- RS.Heartbeat:wait()
- end
- coroutine.wrap(function()
- local PortalCF = PortalPM.CFrame
- local PortalCF2 = PortalCF * CFrame.new(1.4, 0, 0)
- local PortalCF3 = PortalCF * CFrame.new(-1.4, 0, 0)
- local PortalCF4 = PortalCF * CFrame.new(0, 0, 1.4)
- local PortalCF5 = PortalCF * CFrame.new(0, 0, -1.4)
- local Dist1 = (PortalCF.p - (PortalCF * CFrame.new(0, -1, 0)).p).unit * 8
- local Dist2 = (PortalCF2.p - (PortalCF2 * CFrame.new(0, -1, 0)).p).unit * 8
- local Dist3 = (PortalCF3.p - (PortalCF3 * CFrame.new(0, -1, 0)).p).unit * 8
- local Dist4 = (PortalCF4.p - (PortalCF4 * CFrame.new(0, -1, 0)).p).unit * 8
- local Dist5 = (PortalCF5.p - (PortalCF5 * CFrame.new(0, -1, 0)).p).unit * 8
- while Model.Parent and PortalP.Parent and PortalPM.Parent do
- local TouchRay1 = Ray.new(PortalCF.p, Dist1)
- local TouchRay2 = Ray.new(PortalCF2.p, Dist2)
- local TouchRay3 = Ray.new(PortalCF3.p, Dist3)
- local TouchRay4 = Ray.new(PortalCF4.p, Dist4)
- local TouchRay5 = Ray.new(PortalCF5.p, Dist5)
- local Obj1, ObjPos1 = workspace:FindPartOnRay(TouchRay1, Model, false, true)
- local Obj2, ObjPos2 = workspace:FindPartOnRay(TouchRay2, Model, false, true)
- local Obj3, ObjPos3 = workspace:FindPartOnRay(TouchRay3, Model, false, true)
- local Obj4, ObjPos4 = workspace:FindPartOnRay(TouchRay4, Model, false, true)
- local Obj5, ObjPos5 = workspace:FindPartOnRay(TouchRay5, Model, false, true)
- local Obj = nil
- if Obj1 then
- Obj = Obj1
- elseif Obj2 then
- Obj = Obj2
- elseif Obj3 then
- Obj = Obj3
- elseif Obj4 then
- Obj = Obj4
- elseif Obj5 then
- Obj = Obj5
- end
- if Obj and PortalP.Name ~= "Removing" and isRemoving[PortalP] == nil and Model:findFirstChild(StringNum2) and Obj.Parent.ClassName == "Model" and Obj.Parent:findFirstChild("Torso") and isTeleporting == false and Debounces[Obj.Parent] == nil then
- local PortalP2 = Model[StringNum2]
- local ObjChar = Obj.Parent
- isTeleporting = true
- Debounces[ObjChar] = tick()
- local Portal2CF = PortalP2.PortalPM.CFrame
- local hasTeleported = false
- local isDone = false
- local oldRotation = ObjChar.Torso.CFrame - ObjChar.Torso.CFrame.p
- --ObjChar.Torso.Anchored = true
- --ObjChar.Torso.CFrame = CFrame.new((PortalPM.CFrame * CFrame.new(0, 3, 0)).p) * oldRotation
- for iNum = 1, 2 do
- local nowPortal = PortalPM
- if iNum == 2 then
- nowPortal = PortalP2.PortalPM
- end
- coroutine.wrap(function()
- for spinNum = 1, 6 do
- coroutine.wrap(function()
- local nowPortalCFrame = nowPortal.CFrame
- local origAng = math.rad(360/6*spinNum)
- local miniBall = nowPortal:Clone()
- miniBall.Transparency = 1
- miniBall.Parent = nowPortal
- miniBall:ClearAllChildren()
- miniBall.Shape = "Ball"
- miniBall.Material = "Neon"
- miniBall.CanCollide = false
- miniBall.Color = Color3.new(1, 1, 1)
- miniBall.Size = Vector3.new(1, 1, 1)
- miniBall.CFrame = nowPortalCFrame * CFrame.Angles(0, origAng, 0) * CFrame.new(0, 1, -4)
- local SphereMesh = Instance.new("SpecialMesh", miniBall)
- SphereMesh.Name = "SphereMesh"
- SphereMesh.MeshType = "Sphere"
- SphereMesh.Scale = Vector3.new(1, 1, 1)
- for i = 90, 0, -10 do
- miniBall.Transparency = math.sin(math.rad(i))
- RS.Heartbeat:wait()
- end
- miniBall.Transparency = 0
- wait(1/30)
- local oldCF = miniBall.CFrame
- local newCF = oldCF * CFrame.new(0, 6, 0)
- for i = 0, 90, 9 do
- miniBall.CFrame = oldCF:lerp(newCF, math.sin(math.rad(i)))
- RS.Heartbeat:wait()
- end
- miniBall.CFrame = newCF
- isDone = true
- repeat wait(.1) until hasTeleported == true
- wait(1/30)
- local oldSize = SphereMesh.Scale
- local newSize = Vector3.new(0, 0, 0)
- for i = 0, 720, 36 do
- local downNum = (i/360)
- SphereMesh.Scale = oldSize:lerp(newSize, i/720)
- miniBall.CFrame = nowPortalCFrame * CFrame.Angles(0, origAng + math.rad(i), 0) * CFrame.new(0, (7 - downNum), -4)
- RS.Heartbeat:wait()
- end
- miniBall:Destroy()
- isTeleporting = false
- end)()
- end
- end)()
- end
- repeat wait(1/30) until isDone == true
- for i = 1, 10 do
- ObjChar.Torso.CFrame = CFrame.new((Portal2CF * CFrame.new(0, 3, 0)).p) * oldRotation
- end
- --ObjChar.Torso.Anchored = false
- hasTeleported = true
- wait(3)
- Debounces[ObjChar] = nil
- end
- RS.Heartbeat:wait()
- end
- end)()
- PortalPSize = PortalP.Size
- for i = 0, 1, 0.25 do
- if isRemoving[PortalP] then
- return
- end
- PortalP.Size = PortalPSize:lerp(Vector3.new(6, 0.3, 6), i)
- PortalP.CFrame = offsetCFrame * CFrame.new(0, 0.15, 0)
- RS.Heartbeat:wait()
- end
- for i = 90, 0, -3 do
- if isRemoving[PortalP] then
- return
- end
- PortalPM.Transparency = math.sin(math.rad(i))
- RS.Heartbeat:wait()
- end
- PortalPM.Transparency = 0
- coroutine.wrap(function()
- wait(1)
- while PortalP.Parent and Model.Parent do
- local oldCFs = {}
- local trueCFs = {}
- local newParts = {}
- local isDone = false
- for i = 0, 1 do
- coroutine.wrap(function()
- local newPart = PortalP:Clone()
- newPart.Parent = PortalP
- newPart:ClearAllChildren()
- newPart.Color = Color3.new(1, 1, 1)
- newPart.Material = "Neon"
- newPart.Size = Vector3.new(0, 0.2, 0)
- newPart.CFrame = PortalP.CFrame * CFrame.new(0, -0.05, 0) * CFrame.Angles(0, math.rad(90)*i, 0)
- table.insert(newParts, newPart)
- trueCFs[newPart] = PortalP.CFrame * CFrame.new(0, -0.05, 0) * CFrame.Angles(0, math.rad(90)*i, 0)
- local newPartSize = newPart.Size
- for i = 0, 1, 0.1 do
- if isRemoving[PortalP] then
- newPart:Destroy()
- return
- end
- newPart.Size = newPartSize:lerp(Vector3.new(12, 0.2, 0.2), i)
- newPart.CFrame = trueCFs[newPart]
- RS.Heartbeat:wait()
- end
- newPartSize = newPart.Size
- for i = 0, 1, 0.25 do
- if isRemoving[PortalP] then
- newPart:Destroy()
- return
- end
- newPart.Size = newPartSize:lerp(Vector3.new(10, 0.2, 0.2), i)
- newPart.CFrame = trueCFs[newPart]
- RS.Heartbeat:wait()
- end
- isDone = true
- end)()
- end
- repeat wait(1/30) until isDone == true
- if isRemoving[PortalP] then
- for _,v in pairs(newParts) do
- v:Destroy()
- end
- return
- end
- oldCFs[PortalP] = PortalP.CFrame
- for _,v in pairs(PortalP:GetChildren()) do
- if trueCFs[v] then
- oldCFs[v] = trueCFs[v]
- elseif v:IsA("BasePart") then
- oldCFs[v] = v.CFrame
- end
- end
- isMoving[Num] = true
- for i = 0, 1.0001, 0.05 do
- if isRemoving[PortalP] then
- for _,v in pairs(newParts) do
- v:Destroy()
- end
- return
- end
- for p,v in pairs(oldCFs) do
- p.CFrame = v:lerp(v*CFrame.Angles(0, math.rad(90), 0), i)
- if trueCFs[p] then
- trueCFs[p] = v*CFrame.Angles(0, math.rad(90), 0)
- end
- end
- RS.Heartbeat:wait()
- end
- isMoving[Num] = nil
- local newPartSize = newParts[1].Size
- for i = 0, 1, 0.25 do
- if isRemoving[PortalP] then
- for _,v in pairs(newParts) do
- v:Destroy()
- end
- return
- end
- for _,v in pairs(newParts) do
- v.Size = newPartSize:lerp(Vector3.new(12, 0.2, 0.2), i)
- v.CFrame = trueCFs[v]
- end
- RS.Heartbeat:wait()
- end
- newPartSize = newParts[1].Size
- for i = 0, 1, 0.1 do
- if isRemoving[PortalP] then
- for _,v in pairs(newParts) do
- v:Destroy()
- end
- return
- end
- for _,v in pairs(newParts) do
- v.Size = newPartSize:lerp(Vector3.new(0, 0.2, 0), i)
- v.CFrame = trueCFs[v]
- end
- RS.Heartbeat:wait()
- end
- for _,v in pairs(newParts) do
- v:Destroy()
- end
- wait(5)
- end
- end)()
- end
- ------------------------------------------------------------------------------------------------------------------------------------------------------
- local canRun = true
- Mouse.KeyDown:connect(function(Key)
- if canRun then
- canRun = false
- Key = Key:lower()
- local Ok, Err = coroutine.resume(coroutine.create(function()
- local Hit = Mouse.Hit
- local Target = Mouse.Target
- local Surface = Mouse.TargetSurface
- if Key == "e" and Hit and Target and Surface then
- if (not Model:findFirstChild(tostring(1)) or isRemoving[Model[tostring(1)]] == nil) and removePortal(tostring(1)) == false then
- makePortal(1, Hit, Target, Surface)
- end
- elseif Key == "f" and Hit and Target and Surface then
- if (not Model:findFirstChild(tostring(2)) or isRemoving[Model[tostring(2)]] == nil) and removePortal(tostring(2)) == false then
- makePortal(2, Hit, Target, Surface)
- end
- elseif Key == "r" and Hit and Target and Surface then
- local newNum = 1
- if LastPortalNum == 1 then
- newNum = 2
- end
- coroutine.wrap(function()
- removePortal(tostring(newNum))
- end)()
- makePortal(newNum, Hit, Target, Surface)
- end
- end))
- if not Ok then
- print("Error1:", Err)
- end
- canRun = true
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement