Issues with Camera and Tween Service

I’m making the game menu, and I want the camera to move and then stay focused at one point until the player clicks “Play”.
I have 2 parts and what I’m doing is using TweenService to move the camera from one part to the other, here’s the script:

local rs = game:GetService("ReplicatedStorage")
local event = rs.CutsceneEvent
local ts = game:GetService("TweenService")
local csTime = 5

local camera = game.Workspace.Camera
local pos1 = game.Workspace["Pos1"]
local pos2 = game.Workspace["Pos2"]

------------------------------------------------

local info = TweenInfo.new(
	csTime,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.Out,
	0,
	false,
	2
)

event.OnClientEvent:Connect(function()
	
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = pos1.CFrame
	
	local tween = ts:Create(camera, info, {CFrame = pos2.CFrame})
	tween:Play()
	
	wait(csTime)
	
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = pos2.CFrame
	
end)

The problems I’m having:

1 - The camera starts at my character and goes to Pos2, instead of starting at Pos1 then going to Pos2
2 - After the tween ends, the camera goes back to custom mode, I would like it to stay at Pos2 until the player clicks “Play”

Info: The event is fired to the client when a player is added, then it is connected to the tweening function

I do not know if this would help in solving your problems, but you are, according to roblox, supposed to reference the local camera by Workspace.CurrentCamera, not Workspace.Camera.

I already fixed it, but I’ll try doing what u said

1 Like