How to have an object follow another objects rotation with a cap?
What you are looking for is the transformation constraint combined with a limit location constraint.



In this example I am using the rotation of the z-axis to move the location of the x-axis. The mapping in the centre links the source z-axis to the destinations x-axis. The source and destination amounts provide a way to scale the transformation, when the source is at 0 degrees the destination will be at 0 and when the source is at 180 degrees the destination will be at 5, so 180 degrees rotation moves 5 units. If you change the destination location to 0 and 40 then the 180 degrees rotation will give 40 units of movement.

I then added a limit location so that the object will only move from -4 to 4 on the x-axis.