Arm that follows the mouse

Hi I’m making a 2.5D game on UPBGE, but I’m having a problem, I want my player’s arm to align with the cursor or rotate according to the mouse position, but I’m not getting it, I managed it in part but only it works when the player orientation is 180 degrees, but when the position is 0 it doesn’t work, and the alignment is not 100% accurate, here is my code, if necessary I upload my .blend:

        self.cam = bge.logic.getCurrentScene().active_camera
        
        mPos = bge.logic.mouse.position
        posFinal = self.cam.getScreenVect(*mPos)
        self.object.alignAxisToVect([0, target[1], target[2]], 1, 1)
        self.object.alignAxisToVect([1, 0, 0], 0, 1)

You can use the inverse kinematics of the constraints of the bone in order for the bone to follow a specific object - for example, a cube, also do not forget to update the armature so that there is a procedural execution, and moving the cube with the mouse, the hand with the inverse kinematics binding will follow the cube and behave accordingly

Thank you friend