I'm trying to use a scriptable camera but the issue I'm having is I can't figure out how to get the player to rotate with the mouse just like when the camera is custom and you have mouselock enabled. Can anyone help? Here's my code:

local player = game.Players.LocalPlayer
local uis = game:GetService('UserInputService')
local rs = game:GetService('RunService')
local ffc = game.FindFirstChild
local ffa = CFrame.fromAxisAngle
local cf = CFrame.new
local v2 = Vector2.new
local v3 = Vector3.new
local atan = math.atan
local tan = math.tan
local rad = math.rad
local clamp = function(v, l, h) if v > h then return h elseif v < l then return l end return v end
local pi = math.pi
local cam = game.Workspace.CurrentCamera
local camera = {}





do -- Camera Scope
	local limit = rad(89)
	camera.rotation = v2()
	
	
	function camera:GetCoef()
		return -atan(tan(rad(cam.FieldOfView)/2)/2.718)/(32 * pi)
	end
	
	
	
	function camera:Rotate(delta)
		local coef = camera:GetCoef()
		local rotation = camera.rotation + delta * coef
		
		camera.rotation = v2(rotation.x, clamp(rotation.y, -limit, limit))
	end
	
	
	
	local function update()
                if not player.Character or not ffc(player.Character, "HumanoidRootPart") then return end
		local rot = camera.rotation
		local rotation = ffa(v3(0, 1, 0), rot.x) * ffa(v3(1, 0, 0), rot.y)
		
		uis.MouseBehavior = "LockCenter"
		cam.CameraType = "Scriptable"
		cam.CFrame = cf(player.Character.HumanoidRootPart.CFrame.p) * cf(0, 1.5, 1) * rotation
		
	end
	
	
	rs:BindToRenderStep("Camera Update", 200, update)
end




do -- Input 
         uis.InputChanged:connect(function(inp, gpe)
		if gpe then return end
		
		local type = inp.UserInputType.Name:lower()
		
		if type == "mousemovement" then
			camera:Rotate(v2(inp.Delta.x, inp.Delta.y))
		end
	end)

end