Tween a camera, change cframe, not part

This is the script:
I’m wondering, how tween a camera, but instead of adding another part, I want to use the same part, but with different cframe.
How?

local camera = workspace.CurrentCamera
local tweenservice = game:GetService("TweenService")
local part = workspace.CameraPart
local tweeninfo = TweenInfo.new(
	2,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In
)
repeat wait()
	camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = workspace.CameraPart.CFrame
local tween = tweenservice:Create(part, tweeninfo, {CFrame = CFrame.new(-15.76, 13.948, 36.421)} )

tween:Play()

You can simply change the part position and then use the tween service to smoothly change the camera position to the part position.

local workspace = game:GetService("Workspace")
local camera = workspace.CurrentCamera
local tweenservice = game:GetService("TweenService")
local part = workspace:WaitForChild("CameraPart")
local tweeninfo = TweenInfo.new(
	2,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In
)
repeat wait()
	camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable

camera.CFrame = workspace.CameraPart.CFrame
part.CFrame = CFrame.new(-15.76, 13.948, 36.421) --				 change part position

local tween = tweenservice:Create(camera, tweeninfo, {CFrame = part.CFrame}) -- 			tween camera

tween:Play()
1 Like

Yep, I wrote part instead of camera, in tween create.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.