Hello, first you have to set camera CFrame to some part you created, and then tween that part to another part. After that simply create another tween going from part to player’s head, you can try using this:
camera.CameraSubject = character.Humanoid
camera.CameraType = "Custom"
camera.CFrame = character.Head.CFrame --- you can make that into a tween if you want
local tweens = game:GetService("TweenService")
local userInput = game:GetService("UserInputService")
local part = workspace:WaitForChild("Part")
local click = part:WaitForChild("ClickDetector")
local camera = workspace.CurrentCamera
local oldCamera = camera.CFrame
click.MouseClick:Connect(function()
click.MaxActivationDistance = 0
oldCamera = camera.CFrame
camera.CameraType = Enum.CameraType.Scriptable
local unit = (camera.CFrame.Position - part.Position).Unit
local distance = (camera.CFrame.Position - part.Position).Magnitude
local tween = tweens:Create(camera, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.lookAt(camera.CFrame.Position - unit * (distance * 0.8), part.Position)})
tween:Play()
tween.Completed:Wait()
click.MaxActivationDistance = 32
end)
userInput.InputBegan:Connect(function(key, processed)
if processed then
return
end
if key.KeyCode == Enum.KeyCode.F then
local tween = tweens:Create(camera, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = oldCamera})
tween:Play()
tween.Completed:Wait()
camera.CameraType = Enum.CameraType.Custom
end
end)
The “BasePart” instance goes wherever you desire in the workspace and the local script goes inside the “StarterPlayerScripts” folder.
When the ClickDetector is clicked the camera is tweened to focus on the BasePart of which the ClickDetector is inside. Pressing the “F” key will free the camera’s focus and tween the camera back to its original position.
You could set the camera to Cameramode Scriptable then use the :Interpolate() in the camera to move it using part CFrame, focus part CFrame and the duration.
Don’t know of this is exactly what you are looking for but it is out there.