Horizontal slider automatic reset

Hi guys,
I have a problem with the horizontal slider and your help would be really appreciated!

I’ve created my simple slider in the OnGUI function and it works fine, but I want the slider thumb automatically reset to value 0 (the middle point of the dragging area) when I release it.

I’ve tried the following code, but I’m not able to reset the position of the thumb

var sliderValue: float = 0;


function OnGUI(){
	 sliderValue01 = GUI.HorizontalSlider(Rect(25,100,150,20),sliderValue,-1,1);
	 if(!Input.GetMouseButtonDown)
	  	sliderValue = 0;
}

Not sure how you want to use the values, but here is a solution:

#pragma strict

var sliderValue: float = 0;
 
function OnGUI(){
     sliderValue = GUI.HorizontalSlider(Rect(25,100,150,20),sliderValue,-1,1);
     
     if (Input.GetMouseButtonUp(0)) {
       sliderValue = 0;
     }
}