How to make a character roll backward

okay, so i have a character who can roll into a ball, when going downhill, this increases his max speed, when rolling uphill, this decreases his max speed, but I want to make it so that when rolling uphill his speed will eventually run out and cause him to roll back down the hill, regardless of player input until they stop rolling. how would I accomplish this?