Controlling Master Volume with one slider?

I want to control all the volume in my game with one slider and have the sound stay that volume throughout all scenes, I’ve written a script but the volume never changes…?

public Slider VolumeSlider;
float masterVolume = 0.0f;
public void Example() {
    masterVolume = VolumeSlider.value;
    AudioListener.volume = masterVolume;
}

For anyone who’s looking at this in the future, here’s the code. :smiley:

public void AdjustVolume (float newVolume) {
    AudioListener.volume = newVolume;
}