Slowly decreasing the background music volume when enemy instantiated

Hello I have this script attached to enemy that gets the slider volume and set it up to the volume I want,
but the problem is that i would like to slowly decrease from currentVolume to -15f and when enemy is destroyed volume goes slowly back up from -15f to what it was. How would I achieve this?
My code looks like this:

    public Slider backgroundMusic;
    public float currentMusicVolume = 0f;

    // Use this for initialization
    void Start () {
        backgroundMusic = GameObject.Find("Music_Slider").GetComponent<Slider>();
        currentMusicVolume = backgroundMusic.value;
        Debug.Log(currentMusicVolume+" in start");
	// Update is called once per frame
	void Update () {
		if(backgroundMusic.value <= -15f)
            backgroundMusic.value = -8f;
    private void OnDestroy()
        backgroundMusic.value = currentMusicVolume;
        Debug.Log("seting back up to what it was "+currentMusicVolume);

Thanks in advance.

The word you are looking for is interpolate, usually referring to linear interpolation, also called lerp in game development.

[SerializeField] private float volumeChangeDuration; // over how many seconds the change lasts
[SerializeField] private float minVolume = -15f;

private float originalVolume; // this is the same as your currentMusicVolume variable

private Slider musicVolumeSlider;

private float elapsedTime = 0;

private bool enemyExists = true;
public void SetEnemyExists (bool value) { // call this with false when the enemy gets destroyed
    if (value != enemyExists) {
        enemyExists = value;
        elapsedTime = 0;

private void Start () {
    musicVolumeSlider = GameObject.Find("Music_Slider").GetComponent<Slider>();
    originalVolume = musicVolumeSlider.value;

private void Update () {
    elapsedTime += Time.deltaTime; // you might want to use Time.unscaledDeltaTime in case you pause your game, but want to music volume to continue changing
    if (enemyExists) {
        musicVolumeSlider.value = Mathf.Lerp(originalVolume, minVolume, elapsedTime / volumeChangeDuration);
    else {
        musicVolumeSlider.value = Mathf.Lerp(minVolume, originalVolume, elapsedTime / volumeChangeDuration);

Of course, it can be done in various ways, this isn’t necessarily the best, it would be better with coroutines. What you can’t do unfortunately is to do something over time when OnDestroy() is triggered, because at that point this script is destroyed as well, so Update() and coroutines will not be executed anymore.

Use Time.deltatime
Like this
backgroundMusic.value = -8f * Time.deltatime;