Automatically load a save file instead of game over. (RPG Maker MV)

I want my game to automatically load the last save file after the player's death without making him go through the title screen or load the save file menu.
My problem is that this script doesn't work for me, since it fails to load several plugin commands for some reason.

if (DataManager.loadGame(1))
{
$gamePlayer.reserveTransfer($gameMap.mapId(),
$gamePlayer.x, $gamePlayer.y);
$gamePlayer.requestMapReload();
SceneManager.goto(Scene_Map);
}

I could use this one, which works absolutely fine, but it makes the player select the save file which I don't want him to do. It has to be automatic.

SceneManager.push(Scene_Load);

So is there any other way to forcefully load a save file or somehow fix the first script?
here is a plugin for it: Custom GameOver Behavior, I think you need to set this
up in the way you want, but it's prett easy 🙂
here is a plugin for it: Custom GameOver Behavior, I think you need to set this
up in the way you want, but it's prett easy 🙂
Thank you but it's just giving me the same set of errors as the first script call I'm afraid.
Moderator note: Moved to Learning JavaScript.Plugin Support would also be an appropriate place for this, but I feel like this is more about fundamentals than usage, so you'll probably get the best answers in Learning JS.

Original thread: https://forums.rpgmakerweb.com/threads/automatically-load-a-save-file-instead-of-game-over-rpg-maker-mv.129957/