DontDestroyOnLoad doesnt work ouside editor

In my game, I have a game manager. I need this to persist between loading stages. When I hit the play button from the editor, it works fine. I navigate from the start menu to the character select menu and I can select my character.

When I build, I can’t use the character select button because of a null reference error exception. This same code works fine when I just hit the play button from the editor.

if (gm.gameMode.Equals(“Single”))

gm - is the name of the object that was supposed to persist on each level.

may be this will help

I understand how it works. My issue is that it only works in the editor. When create a build, it is not working and I get null reference errors when trying to access it.