Without showing how your movement system is set up, it will be difficult to get a specific answer.
The min() expression may be of use. min(maxdistance, selecteddistance) would return the smaller of the two values - either the maximum distance they are allowed to move, or the selected distance that the player would want to move.