Saving a function

Hi all, I have a problem.

I want to save a function but I don’t know how to do this. I have made some speakers in diffrent scenes, and they set the music on and off when you click it. But when you go to scene 1 and you set the music on and than go to scene 2, you can’t set the music off because its standard stand off. So I thought maybe I can save it with playerprefs. I have seen alot of video’s about it but not about saving things like this. I’m not a pro in unity I use it now for 5 months and C# too. So I hope somebody can help me with this problem.

The script for the speaker to set the music on:

    public GameObject henk;

 public void ChangeToScene (int sceneToChangeTo) {
        henk.SetActive(false);

    }

The script for the speaker to set the music off:

    public GameObject henk2;
   
   public void ChangeToScene (int sceneToChangeTo) {
        henk2.SetActive(true);
       
    }

The script is connected via an OnClick.

Thanks!

if you wanted something to move the settings from one scene to the next you could use PlayerPrefs to save the value and load it again in the next scene or you could use a signleton to allow the value to be accessible throughout all scenes whilst the game is active.

Unity - Scripting API: PlayerPrefs - PlayerPrefs
http://unitypatterns.com/singletons/ - Singletons

ok, thanks for your reaction. I will check it out