How to Inverse Vector3.Distance

Hi everyone,i struggling whole day with this.
I’m truing to setup basic scene for simple app/game (cute robot will balance with sphere).
Sphere is part of him(legs,if you want that way).
Because i’m new in programming(.js) solution for me(no angles,no complicated math) was to use “Vector3.Distance” so i can work with actual numbers.
Solution i choosed for balansing our robot are simple “sensors”(sensors in my project are simple primitive shape(object1) which measure distance(Vector3.Distance) to other primitive shape(object2) as you can see in picture below).
Idea behind all is to measure distance and when distance is decreasing,sphere needs to move faster until point where i will code optimal distance where sphere will stop to be influenced by that particular sensor.Trouble is as you can see in my code,sphere doing opposite and she slowing down.

    #pragma strict
    var object1 : GameObject;
    var object2 : GameObject;
    var ObjToRotate : Transform;
    var ObjToRotate2 : Transform;
    var target: Transform;
    ////////////////////////////
    function Start () {}
    ///////////////////////////
    function Update () {
    
    var distance : float;
    distance = Vector3.Distance (object1.transform.position, object2.transform.position);
          if (distance < 2){
             var speed : float;
             speed = distance;
             Debug.Log("Vrtimo sferu za/spin sphere" + distance);
             ObjToRotate.transform.RotateAroundLocal(Vector3.right,45 * Time.deltaTime * speed);
                                 
             ObjToRotate2.transform.LookAt(target); 
          } 
    
    
}

Picture of my scene>

Ignore “ObjToRotate2 and target” because it just steer parent(EmptyGameObject) of “sphere” to look into my target which is sensor(object1) = for result i have sphere which can switch rotation to other sensor < and that part of code doing fine for me.

Conclusion: Sphere must spin faster as Vector3.Distance decrease and oposite,how to do that? O.o
Thank you so much for time!
I usually work over 10h per day on games all days in month and when its hard i simple work and find somehow solutions,but in this case i don’t see what i need even to search for

If you want speed to decrease when distance is larger and increase when distance is smaller, you should do something like

speed = 1/distance;