How to check if slider is moving?

Hey, how to check if slider is moving? It should do this stuff when moving and then stop when not moving slider.

import UnityEngine.UI;

var obj = GameObject("");								
	var animName = obj.GetComponent.<Animation>();			
		var whatAnimation = "";									
		
var animWrapMode = WrapMode.PingPong;

var SliderPos : float;
var animationSlider = GetComponent(UnityEngine.UI.Slider);

var movingSlider = false;

function Start () {
	
	animationSlider.direction = Slider.Direction.LeftToRight;
	animationSlider.minValue = 0;
	animationSlider.maxValue = 1;
	
	animName[whatAnimation].enabled = false; 			
	animName[whatAnimation].weight = 1;					
	animName[whatAnimation].wrapMode = animWrapMode;	
		
	}
	
function Update() {
	animName[whatAnimation].normalizedTime = SliderPos; 
		//movingSlider = false;
	
	if(movingSlider) 
	{
	animName[whatAnimation].enabled = true; 			
	}
	else
	{
		animName[whatAnimation].enabled = false; 			
	}
	
	}

function moveSlider(newPos : float) {
	SliderPos = newPos;
}

This piece is where things should be changed

if(movingSlider) 
     {
     animName[whatAnimation].enabled = true;             
     }
     else
     {
         animName[whatAnimation].enabled = false;             
     }

Look at the slider in the Inspector. At the bottom is an OnValueChanged. Click on the + and in the slot that appears drag the gameObject with your script on it to that.

Add a public function to your script to set a bool to true and record the Time.time when it set to true as a float.

Then in Update if that bool is true play the animation and check if Time.time is greater than that float, if it is set the bool to false so the next frame the animation doesn’t play.

Now back to OnValueChanged from the dropdown select YourScriptName → YourPublicFunctionName.

Hope that makes sense! :¬)