Rotate camera around part using mouse

  1. What do i want to achieve?
    I want to make camera rotate depending on player mouse position

  2. What is the issue?
    so the issue is camera rotates by its own axis, so rotations are getting weird
    robloxapp-20240827-1658217.wmv (1,7 МБ)

  3. What solutions have i tried so far?
    I tried searching on forum, but only found how to rotate camera around part by only one axis

Here is the code

mouse.Move:Connect(function()
    if UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) and EditingWeapon then
        rotatedCFrame = rotatedCFrame.Rotation
        rotatedCFrame *= smith.CFrame * offset * smith.CFrame:ToWorldSpace(CFrame.Angles(math.rad((lasmPos.Y - mouse.Y)/5), math.rad((lasmPos.X - mouse.X)/3), 0))
        cam.CFrame = smith.CFrame:ToWorldSpace(rotatedCFrame)
        cam.CFrame = CFrame.new(cam.CFrame.Position, smith.Position)
    end
    lasmPos = Vector2.new(mouse.X, mouse.Y)
end) 

I might be a bit confused but have you tried just setting the CameraSubject property in the CurrentCamera under workspace to the part you want to view?

it works, but is there any way to limit angles so the camera will not rotate more than x degrees?