Cannot read property 'name' of null

Ik this isn't a shocker but idk much about code ;-;
I'm getting this error message after i try to load any existing saves? I use the DataManager.saveGame(1) command.

The console reads:
TypeError: Cannot read property 'name' of null
at Function.AudioManager.playBgm (rpg_managers.js:1180)
at Game_System.onAfterLoad (rpg_objects.js:239)
at Scene_Load.terminate (rpg_scenes.js:1745)
at Function.SceneManager.changeScene (rpg_managers.js:1998)
at Function.SceneManager.updateMain (rpg_managers.js:1982)
at Function.SceneManager.update (rpg_managers.js:1907)

(theres more if i expand it but idk if that's anything helpful)
Did you delete a song from your project?
Basically all "of null" means that the engine was given a reference that does not exist.

If this happens on loading a savefile, then that means that the savefile contains this reference and is now incompatible to your current project.
In general either because the plugins changed, or a database reference was deleted, or a file was deleted and so on.

In your case it seems to be some data from the audio manager, most likely the BGM that was active when the game was saved.
Did you delete a song from your project?
I don't believe so? i just set the default stuff in system settings to silence.
Basically all "of null" means that the engine was given a reference that does not exist.

If this happens on loading a savefile, then that means that the savefile contains this reference and is now incompatible to your current project.
In general either because the plugins changed, or a database reference was deleted, or a file was deleted and so on.

In your case it seems to be some data from the audio manager, most likely the BGM that was active when the game was saved.
I'm honestly rlly confused ab it, cuz i can create a new game, leave, and immediately continue without changing anything, and it happens
i can create a new game, leave, and immediately continue without changing anything, and it happens
In that case, something in your plugins broke the save/load sequences.
That is admittedly a rarer case, but can happen as well.


We need to see full screenshots of your entire plugin manager with all your plugins and their order to check what might have caused this
I'm guessing you haven't used the correct "save game" script call: it's more than just DataManager.saveGame(1).

Here's an example (for RMMV) that does different things on save success/fail:

// Save to slot 4; on success/failure, play suitable sounds $gameSystem.onBeforeSave(); if (DataManager.saveGame(4)) { StorageManager.cleanBackup(4); SoundManager.playSave(); } else { SoundManager.playBuzzer(); }
$gameSystem.onBeforeSave() records various things, including the current BGM/BGS, so that they can be restored on load.

(This example was copied from the MV / MZ Script Call List.)
Thank you so much ;-; I had that code but there was a small typo or a missing parentheses or something idfk but tysm i love u for this
I'm guessing you haven't used the correct "save game" script call: it's more than just DataManager.saveGame(1).

Here's an example (for RMMV) that does different things on save success/fail:

// Save to slot 4; on success/failure, play suitable sounds $gameSystem.onBeforeSave(); if (DataManager.saveGame(4)) { StorageManager.cleanBackup(4); SoundManager.playSave(); } else { SoundManager.playBuzzer(); }

$gameSystem.onBeforeSave() records various things, including the current BGM/BGS, so that they can be restored on load.

(This example was copied from the MV / MZ Script Call List.)
No worries, it's very easy to make typos when writing code! Happy RPG Making~ 😂

Original thread: https://forums.rpgmakerweb.com/threads/cannot-read-property-name-of-null.157992/