How to save slider values?

I was wondering if anyone had any way to save slider values i dont really have a script cause all the things i have tried will not work cause i cant import the slider into the actual reference box on the script and it will not let me directly find the slider in the script.

public class PlayerPrefsManager{

	const string MasterVolumeSaveKey ="Master Volume";
	public static float Volume;
	/// <summary>
	/// Gets the master volume.
	/// </summary>
	/// <returns>The master volume.</returns>
	public static float GetMasterVolume ()
	{
		Volume = PlayerPrefs.GetFloat (MasterVolumeSaveKey);
		return Volume;
	}

	/// <summary>
	/// Sets the master volume.
	/// </summary>
	/// <param name="value">Value.</param>
	public static void SetMasterVolume (float value)
	{
		if (value >= 0f && value <= 1f) {
			PlayerPrefs.SetFloat (MasterVolumeSaveKey, value);

		} else {
			Debug.LogException (new System.Exception ("Music volume slider out of range. Set slider between 0 and 1 and Not whole numbers."));
		}
	}
}

to use:

public Slider VolumeSlider;
public static float volume;

void Update(){
    volume = PlayerPrefsManager.GetMasterVolume("MasterVolume");
    OnChangeVolume(VolumeSlider.value);
}

void OnChangeVolume(float value){
    PlayerPrefsManager.SetMasterVolume("Master Volume",  VolumeSlider.value);
}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Slidersaver : MonoBehaviour
{

    public Slider xslider;


    void Start()
    {
       xslider = GameObject.Find("Slider").GetComponent<Slider>().value;
       xslider.value = PlayerPrefs.GetFloat("OptionScore");

    }

    void Update()
    {
        PlayerPrefs.SetFloat("OptionScore", xslider.value);
    

    }
}

Okay thanks for the comments but the reason i have 2 different things calling the slider is because nither of the ways i tryed worked but thanks for thr help i will try that

Here’s your problem. You never use Playerprefs.Save(). Try adding this to the script to make it save each time you load a new scene.

private void OnDisable () {
        Playerprefs.Save ()
}

Everything else here seems good to go.