How to make an animation play using a slider or scroll box as a scrub bar?

I have been trying and trying, but I cant seem to figure out how to correctly approach this issue. We see it in game like Arkham origins, and Cyber punk 2099.

I want to impost an animation, or several animations, and I want to be able to play an animation by scrubing a slider or scrubbar forward, and rewind by scrubbing it backward. Ideally, Id like to hit be able to hit play and stop and stuff too. But I just need some help on how to get the logic for this in place.