Tween to Player's Camera

Okay so, I’ve been struggling to find a tutorial or post anywhere on how to make this. I’m looking for a way to have it so the player’s camera is on a camera part, but then tweens back to the player’s default camera. How would I achieve this?

4 Likes

Use lerp, make the camera cframe tween to the player’s head or anywhere you want, then set the camera type to custom, it’s that easy.

Don’t forget to do it on localscript or it’s not gonna work. CFrame | Documentation - Roblox Creator Hub

Also, here is a video that also has a beginner tutorial on camera manipulation.

Thanks! Although, I have a problem. This is my script, it works fine, but it tweens quite far above the position I told it to, I’m honestly not sure why

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local tiC = TweenInfo.new(4, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local tInC = {CFrame = Player.Character.HumanoidRootPart.CFrame}
local createInC = ts:Create(Camera, tiC, tInC)

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		createInC:Play()
		wait(4)
		Camera.CameraType = Enum.CameraType.Custom
	end
end)
1 Like

What do you mean it tweens quite far from the position? Could you try send a gif of what it does? So i can get some knowledge on how to manage that.

It tweens, I’d say, maybe 7 studs up from the head’s position, no clue why. I’ll try and see if I can make a gif.

Alright, good luck on your issue.

I wrote a detailed reply to another user’s post regarding tweening the camera from the head to another part. Although you don’t have the exact same problem here, it should still help you.

To tween back to the head, code it in a local script. Then, use tween service and make the result to:

game.Players.LocalPlayer.Camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid

Thanks for this! I’ll have a look and let you know if it works. :smile:

Thank you for this but I’m a little confused at how to do this. Here’s what I wrote:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local tiC = TweenInfo.new(4, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local tInC = {CFrame = Player.Character.Humanoid}
local createInC = ts:Create(Camera, tiC, tInC)

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		createInC:Play()
	end
end)

What should I do?

Make the camera lerp to the player’s head like what i did and at the end of the tween, make it so the camera’s subject is the player character’s head.

Change CFrame to CameraSubject.

That will make the camera’s position a bit weird than the usual.

Was getting hopeful but got this error.

TweenService:Create property named ‘CameraSubject’ cannot be tweened due to type mismatch (property is a ‘Object’, but given type is ‘Instance’)

`

I don’t know why, but this looks like it’s a spectating script. If you follow a tutorial about this, you can apply that knowledge in here.