How to adjust camera when crouching

You can write your topic however you want, but you need to answer these questions:

  1. I want the player’s camera to adjust when the crouching and to stay adjusted until uncrouched.

  2. When crouching, the camera doesn’t follow the player anymore, when the player walks and crouches, the camera stays in the same spot before they started walking. And for keeping the camera adjusted while crouching, i don’t know how. Here’s a vide on what i mean: 2021-07-16 16-04-32

  3. I’ve tried to constantly update the camera to the player’s position, but it seems to be ignored when lerping

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

User.InputBegan:Connect(function(Key)
	if Key.KeyCode == Enum.KeyCode.C then
		local ZoomOut = TweenInfo.new(.8, Enum.EasingStyle.Quart,Enum.EasingDirection.Out,0,false,0)
		local Test = tweenService:Create(workspace.Camera,ZoomOut,{CFrame = camera.CFrame:ToWorldSpace(CFrame.new(0,3,0))})
		Test:Play()
	end
end)
2 Likes

I see, you need to make the camera type scriptable.

camera.CameraType = Enum.CameraType.Scriptable

Add that in your script then your crouch system will work.

1 Like

The movement is being ignored because the default camerascripts will modify the camera.

I think the easiest way to modify the camera like this while using the default camera script (to preserve camera motion) is to modify the character’s Humanoid.CameraOffset property.

Not sure how your script is exactly located and written,. but here is something that you could work off of:

I created a script in StarterCharacter with this source.

local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local Client = Players.LocalPlayer
local Camera = workspace.CurrentCamera
local Character = Client.Character
local Humanoid = Character:WaitForChild("Humanoid")

local Crouching = false

local ZoomOutSettings = TweenInfo.new(.8, Enum.EasingStyle.Quart, Enum.EasingDirection.Out, 0, false, 0)
local ZoomOut = Vector3.new(0, 3, 0)
local ZoomInSettings = TweenInfo.new(.8, Enum.EasingStyle.Quart, Enum.EasingDirection.Out, 0, false, 0)
local ZoomIn = Vector3.new(0, 0, 0)
	
local function DoCrouch(Input, Busy)
	if Busy then return end
	
	if Input.KeyCode == Enum.KeyCode.C and Crouching == false then
		Crouching = true

		local Crouch = TweenService:Create(Humanoid, ZoomOutSettings, { CameraOffset = ZoomOut })
		
		Crouch:Play()
		Crouch.Completed:Wait()
	elseif Input.KeyCode == Enum.KeyCode.C and Crouching == true then
		Crouching = false
		
		local Stand = TweenService:Create(Humanoid, ZoomInSettings, { CameraOffset = ZoomIn })
		
		Stand:Play()
		Stand.Completed:Wait()
	end
end

UserInputService.InputBegan:Connect(DoCrouch)

2 Likes

Depends on what you are going to change. If you are changing offset or fov then it should be easy to change.

What is the problem?

Thank you, i completely forgot about that property and was trying to over complicate things.