Error while trying to load a save file.

If the player's health is below zero, I'm reloading the last save file and getting this error:

Uncaught typeError: Cannot read property 'width' of null

script for reloading a save file:
Spoiler
if (DataManager.loadGame(1))
{
$gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y);
$gamePlayer.requestMapReload();
SceneManager.goto(Scene_Map);
}

Console:

Spoiler
XQm6jK8.png

It loads the save file only if it's the same map. How can I fix it?

UPD. It seems to be working on certain maps. Not sure why....
You haven't tried to load a game that was saved before you added or deleted maps, have you? Have you changed plugins since that game was saved?

Is that your script snippet? Where is it? How is it being called?

Looks like it might be related to the BindPicturesToMap plugin. Could you please provide a list of your plugins - screenshot from plugin manager?

When you grab a screenshot, please use Alt+PrintScreen so it captures only the active window and not the whole desktop. It makes it easier to read the messages as they're not so small.
You haven't tried to load a game that was saved before you added or deleted maps, have you? Have you changed plugins since that game was saved?
No, I haven't changed anything.

Is that your script snippet? Where is it? How is it being called?
Script call - Parallel event.

I'm also using this to create a save file:

$gameSystem.onBeforeSave();
if (DataManager.saveGame(1)) {
StorageManager.cleanBackup(1);
}


Looks like it might be related to the BindPicturesToMap plugin. Could you please provide a list of your plugins - screenshot from plugin manager?

Spoiler
YQM9PBH.png

54K7jB8.png

When you grab a screenshot, please use Alt+PrintScreen so it captures only the active window and not the whole desktop. It makes it easier to read the messages as they're not so small.
I always forget that. Thanks! 🙂
Okay, to start with, are you certain all your Yanfly plugins are in exactly the right order?

Second, can you please show a screenshot of your event where you're calling that script? A parallel process event that does stuff to the map when a map is already loaded could cause issues. That particular message, on that particular line, is indicating there is no $dataMap loaded.

mmm ... maybe the loading process does some waiting so the $dataMap can be cleared and repopulated, and you're not doing that in your script snippet.
Spoiler: Check out updates first
Okay, to start with, are you certain all your Yanfly plugins are in exactly the right order?
How do I order them properly?
Second, can you please show a screenshot of your event where you're calling that script? A parallel process event that does stuff to the map when a map is already loaded could cause issues. That particular message, on that particular line, is indicating there is no $dataMap loaded.

Spoiler
zuWGNaD.png

mmm ... maybe the loading process does some waiting so the $dataMap can be cleared and repopulated, and you're not doing that in your script snippet.
How can I do that? 😀

Here is a new error:
Spoiler
X8ohhOe.png

UPD 1
Hmm... I think, maybe, this error only appears when I'm starting a New Game while testing and for some reason, it can't load maps the Player has never been at...? I'll do more testing this evening to see if that's the case.
I'd be surprised ...

What if you disable the Bind Pictures to Map plugin?
I'd be surprised ...

What if you disable the Bind Pictures to Map plugin?

You're right. It's doesn't work.
I can't, because, first, it's a very important plugin for my game and, second, I don't think that's the issue since I often get a new error with different plugins.

I guess I'll just have to return the player to the Title Screen or something...

Original thread: https://forums.rpgmakerweb.com/threads/error-while-trying-to-load-a-save-file.112787/