Need help with camera position

Camera is a bit broken, please help

Here is a video: https://www.youtube.com/watch?v=PrSFrZZcUwQ

Here is a script

local ViewAccessories = false
local ViewModels = false

Plr = game.Players.LocalPlayer
Char = Plr.Character or Plr.CharacterAdded:wait()
Human = Char:WaitForChild("Humanoid")
Cam = game.Workspace.CurrentCamera

Plr.CameraMaxZoomDistance = 400 -- This is how much you can zoom out the camera, you can also change it! Put what number do you want for ex: 203 or 50, etc. Hope I helped you! And if you want, you can DELETE this "green" texts. (The green texts don't affect the SCRIPT, so you can let the text in the script, or you can just DELETE them!).
Plr.CameraMinZoomDistance = 0.5
Cam.FieldOfView = 100 -- Things get trippy if we don't do this.
Human.CameraOffset = Vector3.new(0,-0.25,-1.5)

local function Lock (part)
	if part and part:IsA("BasePart") and part.Name ~= "Head" then
		part.LocalTransparencyModifier = part.Transparency
		part.Changed:connect(function (property)
			part.LocalTransparencyModifier = part.Transparency
		end)
	end
end

for i, v in pairs (Char:GetChildren()) do
	if v:IsA("BasePart") then
		Lock(v)
	elseif v:IsA("Accessory") and ViewAccessories then
		if v:FindFirstChild("Handle") then
			Lock(v.Handle)
		end
	elseif v:IsA("Model") and ViewModels then
		for index, descendant in pairs (v:GetDescendants()) do
			if descendant:IsA("BasePart") then
				Lock(descendant)
			end
		end
	end
end

Char.ChildAdded:connect(Lock)

Cam.Changed:connect(function (property)
	if property == "CameraSubject" then
		if Cam.CameraSubject and Cam.CameraSubject:IsA("VehicleSeat") and Human then
			-- Vehicle seats try to change the camera subject to the seat itself. This isn't what want.
			Cam.CameraSubject = Human;
		end
	end
end)

Can you be more specific? What parts of the script are broken? Also, make sure you name things correctly.

Do you mean the camera kind of disconnecting of the body?

You have to fix it by changing the humanoid camera offset whenever the player crouches, Since the camera isn’t connected to the head it’s connected to the humanoid root part which is not animated.

like you did here

Human.CameraOffset = Vector3.new(0,-0.25,-1.5)

also can you show the crouch script so I can help you more?

1 Like

Here is crouch script

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

local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local CrouchAnimation = script:WaitForChild("CrouchAnimation")
local CrouchTrack = Humanoid:LoadAnimation(CrouchAnimation)

local IdleAnimation = script:WaitForChild("IdleAnimation")
local IdleTrack = Humanoid:LoadAnimation(IdleAnimation)

local CameraInfo = TweenInfo.new(
	0.3,
	Enum.EasingStyle.Quint,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local CrouchedGoal = {CameraOffset = Vector3.new(0, -1.75, 0)}
local UncrouchedGoal = {CameraOffset = Vector3.new(0, 0, 0)}

local CrouchedTween = TweenService:Create(Humanoid, CameraInfo, CrouchedGoal)
local UncrouchedTween = TweenService:Create(Humanoid, CameraInfo, UncrouchedGoal)

local inCrouch = false

local function Crouch()
	if not inCrouch then
		inCrouch = true
		CrouchedTween:Play()
		Humanoid.WalkSpeed = 8
		CrouchTrack:Play()
		IdleTrack:Stop()
		HumanoidRootPart.CanCollide = false
	else
		inCrouch = false
		CrouchedTween:Cancel()
		UncrouchedTween:Play()
		Humanoid.WalkSpeed = 16
		CrouchTrack:Stop()
		IdleTrack:Stop()
		HumanoidRootPart.CanCollide = true
	end
end

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	-- Проверяем, активно ли поле ввода текста
	if UserInputService:GetFocusedTextBox() then
		return -- Игнорируем ввод, если активен чат
	end

	if input.KeyCode == Enum.KeyCode.C then
		Crouch()
	end
end)

Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if inCrouch then
		if Humanoid.MoveDirection.Magnitude > 0 then
			if not CrouchTrack.IsPlaying then
				IdleTrack:Stop()
				CrouchTrack:Play()
			end
		else
			if not IdleTrack.IsPlaying then
				CrouchTrack:Stop()
				IdleTrack:Play()
			end
		end
	else
		CrouchTrack:Stop()
		IdleTrack:Stop()
	end
end)


local CrouchedGoal = {CameraOffset = Vector3.new(0.25, -1.75, -1.75)} --  This is the changed one
local UncrouchedGoal = {CameraOffset = Vector3.new(0, 0, 0)}

Your code already has it ready, but the camera offset wasn’t correctly at the head.
Just replace the crouched goal line in your original script with the new one. However you might need to fiddle with it until you get the right offset, i can’t test it for you.

Thank you very much! /////////////////////////////

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