Spinner for distance between objects

Hello, can anyone simply explain me how can I achieve this?

I want to have spinner in my script which will manipulate distance between two objects/groups.
Spinner start on value 0. (current position of objects) and can be manipulated to 1 and -1 which will means 1 meter distance or -1 meter.
Simple example:

Thanks :)