local O=vector.create(0,1.5,0)local c=vector.create(1,.77,0)local M=vector.create(1,-1,0)local y=(UserSettings()):GetService("\085\115\101\114\071\097\109\101\083\101\116\116\105\110\103\115")local w=require("\064\115\104\097\114\101\100\047\102\114\097\109\101")local J=require("\064\115\104\097\114\101\100\047\119\111\114\108\100")local X=require("\064\115\104\097\114\101\100\047\099\111\109\112\111\110\101\110\116\115")local N=require("\064\099\108\105\101\110\116\047\105\110\112\117\116\047\109\111\117\115\101")return w.on("\105\110\112\117\116",function()local w=N.read_delta()*c if y:GetCameraYInvertValue()then w*=M end for c,M,y in(J:query(X.Input,X.SimulatedRig)):iter()do local J=M.camera_vector M.camera_vector=vector.create(math.clamp(J.X+w.Y,-89,89),(J.Y+w.X)%360,0)local X=CFrame.fromEulerAnglesYXZ(-M.camera_vector.X,-M.camera_vector.Y,0)workspace.CurrentCamera.CFrame=CFrame.new(y.root.Position+O)*X end end)
local HEAD_HEIGHT = vector.create(0, 1.5, 0)
local CAMERA_SENS = vector.create(1, 0.77, 0)
local INVERT_MOUSE = vector.create(1, -1, 0)

local UserGameSettings = UserSettings():GetService("UserGameSettings")

local frame = require("@shared/frame")
local world = require("@shared/world")
local components = require("@shared/components")
local mouse = require("@client/input/mouse")

return frame.on("input", function()
	local input_vector = mouse.read_delta() * CAMERA_SENS

	if UserGameSettings:GetCameraYInvertValue() then
		input_vector *= INVERT_MOUSE
	end

	for _, HumanoidInput, LocalHumanoid in world:query(components.Input, components.SimulatedRig):iter() do
		local existing_camera_vector = HumanoidInput.camera_vector

		HumanoidInput.camera_vector = vector.create(
			math.clamp(existing_camera_vector.X + input_vector.Y, -89, 89),
			(existing_camera_vector.Y + input_vector.X) % 360,
			0
		)

		local coordinate_frame =
			CFrame.fromEulerAnglesYXZ(-HumanoidInput.camera_vector.X, -HumanoidInput.camera_vector.Y, 0)

		workspace.CurrentCamera.CFrame = CFrame.new(LocalHumanoid.root.Position + HEAD_HEIGHT) * coordinate_frame
	end
end)
