Advertisement
Richbadniss

This wont work

Oct 29th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.91 KB | None | 0 0
  1. local character = script.Parent
  2. local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
  3. local humanoid = character:WaitForChild("Humanoid")
  4. local camera = game.Workspace.CurrentCamera
  5. local tweenService = game:GetService("TweenService")
  6.  
  7. local currentDoor = nil
  8. local teleporting = false
  9. local alive = true
  10.  
  11. camera.CameraType = Enum.CameraType.Custom
  12. camera.CameraSubject = character.Humanoid
  13. for _, v in ipairs(game.Lighting:GetChildren()) do
  14.     if v.Name == "TeleportLighting" then
  15.         spawn(function()
  16.             tweenService:Create(v, TweenInfo.new(1), {Brightness = 0}):Play() wait(1) v:Destroy()
  17.         end)
  18.     end
  19. end
  20.  
  21. local ContextActionService = game:GetService("ContextActionService")
  22. local FREEZE_ACTION = "freezeMovement"
  23. local function enableControls(value)
  24.     if not value then
  25.         ContextActionService:BindAction(
  26.             FREEZE_ACTION,
  27.             function() return Enum.ContextActionResult.Sink end,
  28.             false,
  29.             unpack(Enum.PlayerActions:GetEnumItems())
  30.         )
  31.     else
  32.         ContextActionService:UnbindAction(FREEZE_ACTION)
  33.     end
  34. end
  35. enableControls(true)
  36.  
  37. local function openDoors(value)
  38.     if currentDoor == nil then return end
  39.     local factor = math.pi/1.5 if value == "Close" then factor = 0 end
  40.    
  41.     for _, door in pairs(currentDoor["Doors"]:GetChildren()) do
  42.         tweenService:Create(
  43.             door["Hinge"],
  44.             TweenInfo.new(.4, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out),
  45.             {CFrame = door["Hinge"]["OriginalCFrame"].Value * CFrame.Angles(0, factor, 0)}
  46.         ):Play()
  47.     end
  48. end
  49.  
  50. humanoidRootPart.Touched:Connect(function(hit)
  51.     if hit.Name == "Trigger" and hit.Parent.Name == "DoorSystem" then
  52.         if currentDoor == nil and alive then
  53.             currentDoor = hit.Parent
  54.             openDoors("Open")
  55.         end --Open Doors
  56.     elseif hit.Name == "TP" then
  57.         if currentDoor ~= nil and not teleporting and alive then
  58.             teleporting = true
  59.             enableControls(false)
  60.             local neon = currentDoor["Neon"]
  61.             humanoid.WalkToPoint = currentDoor.WalkTo.Position
  62.             camera.CameraType = Enum.CameraType.Scriptable
  63.             tweenService:Create(camera, TweenInfo.new(2), {CFrame = neon.CFrame * CFrame.new(0, 0, -1 + -neon.Size.Z/2) * CFrame.Angles(0, 0,0)}):Play()
  64.             wait(0.5)
  65.             local CC = Instance.new("ColorCorrectionEffect", game.Lighting)
  66.             CC.Name = "TeleportLighting"
  67.             CC.Brightness = 1
  68.             wait(3)
  69.             if alive then
  70.                 camera.CameraType = Enum.CameraType.Custom
  71.                 camera.CameraSubject = character.Humanoid
  72.                 humanoidRootPart.CFrame = currentDoor["Target"].CFrame
  73.                 humanoid.WalkToPoint = currentDoor["Target"].Position
  74.                 tweenService:Create(CC, TweenInfo.new(1), {Brightness = 0}):Play()
  75.                 enableControls(true)
  76.                 teleporting = false
  77.             end
  78.         end
  79.     end
  80. end)
  81.  
  82. humanoidRootPart.TouchEnded:Connect(function(hit)
  83.     if hit.Name == "Trigger" and hit.Parent.Name == "DoorSystem" and currentDoor ~= nil then
  84.        
  85.         openDoors("Close")
  86.         currentDoor = nil
  87.     end
  88. end)
  89.  
  90. character.Humanoid.Died:Connect(function() alive = false end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement