[HELP] Camera Offset Not Working First Person Script

Hi I Making A Toggleable First Person Mode But I Get A Error Help Please.

local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local thirdperson = true

local UIS = game:GetService("UserInputService")

player.CameraMaxZoomDistance = 14
player.CameraMinZoomDistance = 10 

UIS.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.V then
		if thirdperson ~= false then
			thirdperson = false
			
			player.CameraMinZoomDistance = 0.5
			player.CameraMaxZoomDistance = 0.5
			camera.FieldOfView = 90

			humanoid.CameraOffset = Vector3.new(0, 0, -1)
			
			repeat wait()

				humanoid.CameraOffset = Vector3.new(0, 0, -1)
				for childIndex, child in pairs(character:GetChildren()) do
					if child:IsA("BasePart") and child.Name ~= "Head" then

						child:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
							child.LocalTransparencyModifier = child.Transparency
						end)

						child.LocalTransparencyModifier = child.Transparency

					end
				end

				camera:GetPropertyChangedSignal("CameraSubject"):Connect(function()
					if camera.CameraSubject:IsA("VehicleSeat") then
						camera.CameraSubject = humanoid
					end
				end)
			until thirdperson == false
		elseif thirdperson ~= true then
			thirdperson = true
			
			player.CameraMaxZoomDistance = 14
			player.CameraMinZoomDistance = 10 
			camera.FieldOfView = 70
			humanoid.CameraOffset = Vector3.new(0,0,0)
			
			camera.CameraSubject = humanoid
		end
	end
end)

Don’t expect the client to load the character instantly; change character delcaration to this:

local character = player.Character
if not character or not character.Parent then
    character = player.CharacterAdded:Wait()
end

I suggest reading the output because it really helps.
Edit: You did not specify what problem/error is you just only said that it just does not work. Was that your problem?

1 Like