Image with mouse movement

I managed to make the movement of the ball follow the movement of the mouse, but I cannot create a “limit”

this is the code:

This is the error:

Does anyone know how I can resolve this?