I’ve been trying to make a cutscene for my 2D platformer but everytime I fire the cutscene, the cutscene starts from the player and not the first camera.
Here’s the code I used for the cutscene. And if you are wondering, the custome camera type is set to custom.
local TweenService = game:GetService("TweenService")
local camera = game.Workspace.Camera
local cutsceneTime = 3
local tweenInfo = TweenInfo.new(
cutsceneTime,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
function tween(part1,part2)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part1.CFrame
local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
tween:Play()
wait(cutsceneTime)
camera.CameraType = Enum.CameraType.Custom
end
wait(2)
game.ReplicatedStorage.Cutscene.OnClientEvent:Connect(function()
tween(game.Workspace.Camera1,game.Workspace.Camera2)
end)
I’ve rewritten your code and it works fine on my client, if it does not work for you let me know. the problem might just be the custom camera controller.
local TweenService = game:GetService("TweenService")
local CurrentCamera = workspace.Camera
local cutsceneTime = 3
local tweenInfo = TweenInfo.new(
cutsceneTime,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
function tween(part1,part2)
CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = part1.CFrame
local tween = TweenService:Create(CurrentCamera, tweenInfo, {CFrame = part2.CFrame})
tween:Play()
wait(cutsceneTime)
CurrentCamera.CameraType = Enum.CameraType.Custom
end
wait(2)
game.ReplicatedStorage.Cutscene.OnClientEvent:Connect(function()
tween(workspace.Camera1,workspace.Camera2)
end)
If the problem is that it’s cancelling too early, then you need to adjust the cutscene time.
function tween(part1,part2)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part1.CFrame
local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
tween:Play()
wait(cutsceneTime)
camera.CameraType = Enum.CameraType.Custom
end
What you could instead do is have the time as an argument for the function to change it based on when it was called.
function tween(part1,part2, cutsceneTime) --notice the extra argument here
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part1.CFrame
local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
tween:Play()
wait(cutsceneTime)
camera.CameraType = Enum.CameraType.Custom
end
Remove the cutsceneTime variable and you should be good to call the function with the time.