Slider problem

Hi i created energy bar in my canvas. It is normal slider.
I wrote a script in c# to control the slider value, but it still gives me an error.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;

public class slider : MonoBehaviour {

public slider energy;

double Evalue = 0;

	void Update () {

	Evalue = energy.value;
	}

}

How to make it start working. I cannot find a solution on internet.

You should use the Slider’s onValueChanged event.

You can either add a listener to it from the inspector, or by code.