Changing camera CFrame for crouch system

uis.InputBegan:Connect(function(input, process)
	if input.KeyCode == Enum.KeyCode.LeftControl and not process then
		local x, y, z = cam.CFrame:ToOrientation()
		cam.CFrame = CFrame.new(head.Position - Vector3.new(0, 2, 0), Vector3.new(x, y, z))
	end
end)

I tried making a script which moves the player’s camera downwards by 2 studs when they hold control, what’s currently happening is the camera does not move downwards at all, and the camera seems to slowly point to the same spot every time I press control

I’m trying to base the camera’s position off the character’s head’s position, and the orientation off the camera’s current orientation

You can’t set the camera’s CFrame if the mode isn’t scriptable, for this use CameraOffset in the character’s Humanoid

replace these lines with

game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(0,-2,0)

I totally forgot that you can just use the CameraOffset property from the Humanoid, that’s a little embarrassing

It works flawlessly, thank you for the help

1 Like