Python mouse not working correctly

So I am making a game in which the camera follows the player’s character in a 3rd person view. The code I have is simple:


    mouse = bge.logic.mouse    mouse.position = (.5, .5) #Set the mouse position
    
    rotation = own.localOrientation.to_euler() #Get the rotation of the circle that the camera is parented to
    
    rotation.z += (mouse.position[0] - 0.5) #If the user moves the mouse since when the mouse's position was set, rotate the object on the correct axis
    rotation.x += (mouse.position[1] - 0.5) #Same here but for a different axis
    rotation.y = 0 #Don't need to rotate the y axis
    
    if (degrees(rotation.x) < -60): #This is to keep the camera from rotating to much or too little
        rotation.x = (-60)/180 * pi
    if (degrees(rotation.x) > 24):
        rotation.x = (24)/180 * pi

    own.localOrientation = rotation #Set the rotation of the object

For some reason, the

mouse.position[0 or 1] - 0.5

isn’t doing what’s it’s supposed to because when I run the game, the camera slowly turns on the z and x axis. I tried putting the round function around the 0.5 and that fixed the problem for a few minutes but after making a few other changes, the problem came right back. Any idea on what’s happening?