How to add a function from another class to a Slider's OnValueChanged with AddListener()?

Hello, I’m new to Unity/C# and need quite a bit of help. In my program, I have one UI slider at start and a bunch of prefabs instantiated during runtime. Each prefab has a script that changes its localScale. I want the user to click on a prefab, and the slider’s OnValueChanged list of functions to update so it only changes the dynamic variable of the prefab the user clicked on. The only problem is that the last line of StartScaleMode(), where I use AddListener(), does not seem to work.

The function for adding a function to OnValueChanged :

    public void StartScaleMode()
		GameObject ScaleSlider = GameObject.Find("ScaleSlider");
		Slider SlideScript = ScaleSlider.GetComponent<Slider>();
		Scale script = hit.collider.gameObject.AddComponent<Scale> ();

And the other class, which is attached to the prefabs, is:

   public class Scale : MonoBehaviour {
         public void AdjustSize(float newSize)
	      gameObject.transform.localScale += new Vector3(newSize, newSize, newSize);

onValueChanged is an event taking a float as parameter, so I believe you can do:


Also, I advise you to remove the event listeners beforehand, if you don’t do it already.