Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local character = script.Parent
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- local humanoid = character:WaitForChild("Humanoid")
- local camera = game.Workspace.CurrentCamera
- local tweenService = game:GetService("TweenService")
- local currentDoor = nil
- local teleporting = false
- local alive = true
- camera.CameraType = Enum.CameraType.Custom
- camera.CameraSubject = character.Humanoid
- for _, v in ipairs(game.Lighting:GetChildren()) do
- if v.Name == "TeleportLighting" then
- spawn(function()
- tweenService:Create(v, TweenInfo.new(1), {Brightness = 0}):Play() wait(1) v:Destroy()
- end)
- end
- end
- local ContextActionService = game:GetService("ContextActionService")
- local FREEZE_ACTION = "freezeMovement"
- local function enableControls(value)
- if not value then
- ContextActionService:BindAction(
- FREEZE_ACTION,
- function() return Enum.ContextActionResult.Sink end,
- false,
- unpack(Enum.PlayerActions:GetEnumItems())
- )
- else
- ContextActionService:UnbindAction(FREEZE_ACTION)
- end
- end
- enableControls(true)
- local function openDoors(value)
- if currentDoor == nil then return end
- local factor = math.pi/1.5 if value == "Close" then factor = 0 end
- for _, door in pairs(currentDoor["Doors"]:GetChildren()) do
- tweenService:Create(
- door["Hinge"],
- TweenInfo.new(.4, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out),
- {CFrame = door["Hinge"]["OriginalCFrame"].Value * CFrame.Angles(0, factor, 0)}
- ):Play()
- end
- end
- humanoidRootPart.Touched:Connect(function(hit)
- if hit.Name == "Trigger" and hit.Parent.Name == "DoorSystem" then
- if currentDoor == nil and alive then
- currentDoor = hit.Parent
- openDoors("Open")
- end --Open Doors
- elseif hit.Name == "TP" then
- if currentDoor ~= nil and not teleporting and alive then
- teleporting = true
- enableControls(false)
- local neon = currentDoor["Neon"]
- humanoid.WalkToPoint = currentDoor.WalkTo.Position
- camera.CameraType = Enum.CameraType.Scriptable
- tweenService:Create(camera, TweenInfo.new(2), {CFrame = neon.CFrame * CFrame.new(0, 0, -1 + -neon.Size.Z/2) * CFrame.Angles(0, 0,0)}):Play()
- wait(0.5)
- local CC = Instance.new("ColorCorrectionEffect", game.Lighting)
- CC.Name = "TeleportLighting"
- CC.Brightness = 1
- wait(3)
- if alive then
- camera.CameraType = Enum.CameraType.Custom
- camera.CameraSubject = character.Humanoid
- humanoidRootPart.CFrame = currentDoor["Target"].CFrame
- humanoid.WalkToPoint = currentDoor["Target"].Position
- tweenService:Create(CC, TweenInfo.new(1), {Brightness = 0}):Play()
- enableControls(true)
- teleporting = false
- end
- end
- end
- end)
- humanoidRootPart.TouchEnded:Connect(function(hit)
- if hit.Name == "Trigger" and hit.Parent.Name == "DoorSystem" and currentDoor ~= nil then
- openDoors("Close")
- currentDoor = nil
- end
- end)
- character.Humanoid.Died:Connect(function() alive = false end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement