Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables and services
- local player = game:GetService("Players").LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local camera = workspace.CurrentCamera
- local InputService = game:GetService("UserInputService")
- local TweenService = game:GetService("TweenService")
- -- Tween information
- local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
- local tweenInfo2 = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
- -- Target character and objects
- local billy = workspace:WaitForChild("billy")
- -- Tweens
- local aboveCharacterTween
- local skyTween
- -- Input handling
- InputService.InputBegan:Connect(function(input, gameProcessedEvent)
- if gameProcessedEvent then return end
- aboveCharacterTween = TweenService:Create(camera, tweenInfo, {
- CFrame = CFrame.new(
- (character.PrimaryPart.CFrame * CFrame.new(0, 10, 0)).Position,
- character.PrimaryPart.Position
- )
- })
- skyTween = TweenService:Create(camera, tweenInfo2, {
- CFrame = CFrame.new(
- (character.PrimaryPart.CFrame * CFrame.new(0, 250, 0)).Position,
- character.PrimaryPart.Position
- )
- })
- if input.KeyCode == Enum.KeyCode.E then
- camera.CameraType = Enum.CameraType.Scriptable
- -- Transition to above the character
- aboveCharacterTween:Play()
- aboveCharacterTween.Completed:Connect(function()
- -- Transition to the sky
- skyTween:Play()
- skyTween.Completed:Connect(function()
- -- Switch to the new character
- if player.Character == billy then
- player.Character = workspace[player.Name]
- camera.CameraSubject = workspace[player.Name].Humanoid
- else
- player.Character = billy
- camera.CameraSubject = billy.Humanoid
- end
- --player.Character = billy
- character = player.Character
- local skyTween2 = TweenService:Create(camera, tweenInfo2, {
- CFrame = CFrame.new(
- (character.PrimaryPart.CFrame * CFrame.new(0, 250, 0)).Position,
- character.PrimaryPart.Position
- )
- })
- skyTween2:Play()
- skyTween2.Completed:Connect(function()
- local aboveCharacterTween2 = TweenService:Create(camera, tweenInfo, {
- CFrame = CFrame.new(
- (character.PrimaryPart.CFrame * CFrame.new(0, 10, 0)).Position,
- character.PrimaryPart.Position
- )
- })
- -- Move back to the new character
- aboveCharacterTween2:Play()
- aboveCharacterTween2.Completed:Connect(function()
- camera.CameraType = Enum.CameraType.Custom
- end)
- end)
- end)
- end)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement