You’ll have to link the rotation of the gear with its x-position:
1. Remove any expression from the gear’s rotation, it there’s one in it.
2. Alt-click the rotation and add this expression:
transform.position[0]
3. Move the gear left & right; it will rotate.
4. You’ll probably have to modify the speed of the rotation; you can do this with a bit of guesswork; if it’s going too slowly, add a multiplier on the end, for example to double the speed:
transform.position[0]*2
…or to make it rotate at 25% speed:
transform.position[0]*.25
You could alternatively add an expression slider and use that instead of the “.25” or “2” to give you a speed control slider.
– Paul