First, we need to set the CurentCamera's Camera Type to 'Scriptable'. This will only work with a LocalScript.
local CurrentCamera = workspace.CurrentCamera
CurrentCamera.CameraType = Enum.CameraType.Scriptable -- This means that the player can't move the camera.
Also, please be aware that if you are going to do this when the player joins the game, you do a wait() with no delay. This means that it will wait until the game has finished loading.
Now, we need to create at least 2 parts. I recommend that you make the front surface a motor so that you know where the camera will face. You could also put a decal on the front surface.
Also, make the part invisible. If you can see the other part in the cutscene, it won't look pretty so that's why you should make it invisible.
Now, we need to get the variables we will need:
local TweenService = game:GetService("TweenService")
local CutsceneTime = 5 -- This can be any amount you want. This is in seconds.
local ti = TweenInfo.new(CutsceneTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0) -- The TweenInfo for the cutscene.
This should be your script now:
local CurrentCamera = workspace.CurrentCamera
CurrentCamera.CameraType = Enum.CameraType.Scriptable -- This means the player can't move the camera.
local TweenService = game:GetService("TweenService")
local CutsceneTime = 5 -- This can be any amount you want. This is in seconds.
local ti = TweenInfo.new(CutsceneTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
Now, we need to create a function to tween the camera with the least amount of code possible:
function tween(part1, part2)
CurrentCamera.CFrame = part1.CFrame -- 'part1' is the initial part for the tween.
local tween = TweenService:Create(CurrentCamera, ti, {CFrame = part2.CFrame})
tween:Play()
wait(CutsceneTime) -- Waits until the end of the cutscene.
end
Now, you are basically done! However, to run the code, you need to type the following in any function:
tween(part1, part2) -- 'part1' and 'part2' can be any part you want.
wait(5) -- Wait any amount of time (the following is for ending the cutscene)
CurrentCamera.CameraType = Enum.CameraType.Custom
Now, this should be your end script:
local CurrentCamera = workspace.CurrentCamera
CurrentCamera.CameraType = Enum.CameraType.Scriptable -- This means that the player can't move the camera.
local TweenService = game:GetService("TweenService")
local CutsceneTime = 5 -- This can be any amount you want. This is in seconds.
local ti = TweenInfo.new(CutsceneTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
function tween(part1, part2)
CurrentCamera.CFrame = part1.CFrame
local tween = TweenService:Create(CurrentCamera, ti, {CFrame = part2.CFrame})
tween:Play()
wait(CutsceneTime) -- Waits until the end of the cutscene
end
local CurrentCamera = workspace.CurrentCamera
CurrentCamera.CFrame = part.CFrame -- 'part' can be any part. The camera will be facing out from the front surface of it though.
wait(5) -- Wait any amount of time.
CurrentCamera.CameraType = Enum.CameraType.Custom -- Ends the cutscene and takes you back to the player's perspective.