move object with slide

I wanted to move an object through a slide. I converted the function to use the slide. Now I’m lost. How can I connect it to the object in order to move it?

var hSliderValue : float = 0.0;
var a : float;
    
    public var max : float;
    public var min : float;
    public var slideX : float;
    
    
    function OnGUI () {
       GUI.HorizontalSlider (Rect (25, 25, 100, 30), 0.0, 10.0);
    }
    
    
    
    
    function calculate(){
    
    
    
    
    return ((max-min)*(slideX-0)/(1-0))+min;
    
    
    
    
    }

Try the following code. You’ll need to attach it to the object you want to move.

If you wish to keep the object on-screen, you’ll need to tweak the min and max values, or use some other method.

var min = -10.0;
var max = 10.0;
var sliderPos = Rect(25, 25, 100, 30);

function OnGUI (){
    transform.position.x = GUI.HorizontalSlider(sliderPos, transform.position.x, min, max);
}