Advertisement
ailenkai

Untitled

Dec 4th, 2024 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | None | 0 0
  1. -- Variables and services
  2. local player = game:GetService("Players").LocalPlayer
  3. local character = player.Character or player.CharacterAdded:Wait()
  4. local camera = workspace.CurrentCamera
  5. local InputService = game:GetService("UserInputService")
  6. local TweenService = game:GetService("TweenService")
  7.  
  8. -- Tween information
  9. local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
  10. local tweenInfo2 = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
  11.  
  12. -- Target character and objects
  13. local billy = workspace:WaitForChild("billy")
  14.  
  15. -- Tweens
  16. local aboveCharacterTween
  17. local skyTween
  18.  
  19.  
  20. -- Input handling
  21. InputService.InputBegan:Connect(function(input, gameProcessedEvent)
  22.     if gameProcessedEvent then return end
  23.    
  24.     aboveCharacterTween = TweenService:Create(camera, tweenInfo, {
  25.         CFrame = CFrame.new(
  26.             (character.PrimaryPart.CFrame * CFrame.new(0, 10, 0)).Position,
  27.             character.PrimaryPart.Position
  28.         )
  29.     })
  30.    
  31.     skyTween = TweenService:Create(camera, tweenInfo2, {
  32.         CFrame = CFrame.new(
  33.             (character.PrimaryPart.CFrame * CFrame.new(0, 250, 0)).Position,
  34.             character.PrimaryPart.Position
  35.         )
  36.     })
  37.    
  38.     if input.KeyCode == Enum.KeyCode.E then
  39.         camera.CameraType = Enum.CameraType.Scriptable
  40.         -- Transition to above the character
  41.         aboveCharacterTween:Play()
  42.         aboveCharacterTween.Completed:Connect(function()
  43.             -- Transition to the sky
  44.             skyTween:Play()
  45.  
  46.             skyTween.Completed:Connect(function()
  47.                 -- Switch to the new character
  48.                
  49.                 if player.Character == billy then
  50.                     player.Character = workspace[player.Name]
  51.                     camera.CameraSubject = workspace[player.Name].Humanoid
  52.                 else
  53.                     player.Character = billy
  54.                     camera.CameraSubject = billy.Humanoid
  55.                 end
  56.                 --player.Character = billy
  57.                 character = player.Character
  58.                
  59.                 local skyTween2 = TweenService:Create(camera, tweenInfo2, {
  60.                     CFrame = CFrame.new(
  61.                         (character.PrimaryPart.CFrame * CFrame.new(0, 250, 0)).Position,
  62.                         character.PrimaryPart.Position
  63.                     )
  64.                 })
  65.                
  66.                 skyTween2:Play()
  67.                 skyTween2.Completed:Connect(function()
  68.                     local aboveCharacterTween2 = TweenService:Create(camera, tweenInfo, {
  69.                         CFrame = CFrame.new(
  70.                             (character.PrimaryPart.CFrame * CFrame.new(0, 10, 0)).Position,
  71.                             character.PrimaryPart.Position
  72.                         )
  73.                     })
  74.  
  75.                     -- Move back to the new character
  76.                     aboveCharacterTween2:Play()
  77.                     aboveCharacterTween2.Completed:Connect(function()
  78.                         camera.CameraType = Enum.CameraType.Custom
  79.                     end)
  80.                 end)
  81.  
  82.                
  83.             end)
  84.         end)
  85.     end
  86. end)
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement