How can I make My crouch script offset the camera when I crouch?

Hello, I was wondering if anyone could help me Offset the camera angle when someone crouches in my game, what I mean is, when someone pushes the c button it makes them crouch (that works) and when they let it go they uncrouch (that works). So All I need help with is when they crouch it changes their camera angle to the HumanoidRootPart so it gives the effect that they are lower. So I was wondering how I could make the camera offset a little in front of the HumanoidRootPart. (this is an fps game) here is my script:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Animate 
local Humanoid = player.Character:FindFirstChildWhichIsA("Humanoid")
local char = player.Character or player.CharacterAdded:Wait()
local hrp = char:FindFirstChild("HumanoidRootPart")
local camera = workspace.CurrentCamera

mouse.KeyDown:Connect(function(Key)
	if Key == "c" then
		
		local Animation = Instance.new("Animation", player.Character)
		Animation.AnimationId = "rbxassetid://6924820921"
		Animate = Humanoid:LoadAnimation(Animation)
		camera.CameraSubject = hrp
	
	end
end)

mouse.KeyUp:Connect(function(Key)
	if Key == "c" then
		
		Animate:Stop()
		camera.CameraSubject = Humanoid
	end
end)
2 Likes

I’m on mobile so sorry for the quick msg. Humanoids have a property CameraOffset, look it up! It’s a Vector3! GL with your code!

1 Like

How exactly am I suppose to set the camera offset in a script. I would like an example

Quick example
player.Character.Humanoid.CharacterOffset = Vector3.new(5,0,0)

1 Like

Honestly, you can just edit the humanoids HipHeight property. I do this for my game, and it works very well for that given effect. Just subtract it by a certain offset whenever they crouch, then when they’re up, return it to normal.

Here’s how it looks in my game, if you were wondering:

I hope this helped! :smiley:

3 Likes

When I enter that code in it says CharacterOffset

is not a valid memeber of humanoid, could you maybe help me on this one.

use tweenservice instead of character hip height