Accessing a script from another script in different scene

I’ve been having a lot of trouble with this. I’ve attached Script A to Object A in Scene A and I want to access Script A in Script B attached to Object B in Scene B. And yes, I’ve used DontDestroyOnLoad. It works, but I keep getting null errors because when I try to attach Script A to Script B in the inspector, Script A isn’t there. Note: Script A has Boolean values that I wish to be read by Script B.

I’m trying to make a game which involves choices and after you make a choice, you go to the next scene, but you can go back to the previous scene to change your choice. I want the choices to be saved somewhere, so at the end all the choices you picked will be displayed. Can someone help me out here? I know my question is a bit vague, but if someone can help me with my first problem then that would be helpful. I’ve heard a lot about PlayerPrefs, but it seems a little confusing. I’m not sure I want to go that route right now. I’d rather just stick with the Don’tDestroyOnLoad method for now if I can.

Create a dummy gameobject and attach the script you wish to carry forward to next scene to it. Add Don’tDestroyOnLoad to your script. Now choice is yours either make that script singleton or create static variables. Now make a prefab out of that dummy gameobject. You can now add this prefab to all the scenes you want that script and access that variable using class name directly if you go with static variable.