Camera Manipulation

I have created a script that, when a button is clicked, checks if a player’s cam (string value) is a certain value, and if it is, then it changes the player’s camera to a position where the camera looks down on the player. The variable “cameraPart” is the part that is above the player. The variable “camera” is just the CurrentCamera. Though the code works, I want to either tween it or LERP it, because right now, it just snaps from first person to third person, and I want it to be smoother. Here is the code:

if player.cam.Value == "f" and char:FindFirstChild("HumanoidRootPart") then
		camera.CameraSubject = cameraPart
		cameraPart.CFrame = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(-7, camHeight, 0))
		char.Humanoid.WalkSpeed = 0
		char.Humanoid.JumpPower = 0
		camera.CFrame = CFrame.new(Vector3.new(0, 100, 0), Vector3.new(0, 0, 0))
		camera.FieldOfView = 30
end

How would I either tween it or LERP it?

1 Like

You should probably just use tweening, as it supports more customisation over the style.

local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Circular, Enum.EasingDirection.In) -- You can change these according to your needs
local tween = game:GetService("TweenService"):Create(camera, tweenInfo, {CFrame = CFrameYouWantToSet})
tween:Play()

Thanks. Can I use {camera.CFrame = cameraPart.CFrame}? Because, it is giving me an error when I do this, so I’m not sure what to put.

Simply {CFrame = cameraPart.CFrame} is enough. I made a mistake back there. Sorry.

It works perfectly, thanks so much!

1 Like

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