Save Command Not Working

I'm trying to make my game save the progress when the player dies... but is not working.... i'm getting the error: "Cannot read property 'clamp' of indefined".

I'm using this script call

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

When I save the game manually by the save screen works fine.
You meant while the game over screen appear and exit the game?
This script call below should work.

Code:
$gameSystem.onBeforeSave();
if (DataManager.saveGame(1)) {
   StorageManager.cleanBackup(1);
}
You meant while the game over screen appear and exit the game?
This script call below should work.

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

Same error :/ I got this error when I try to load the saved game data...
Hit F8 when you get the error and post your console log.
two additional questions:
1) what is your complete filepath, from drive letter to index.html?
Something like c:\folder\folder\folder\project\index.html
because if that filepath doesn't follow networking rules, the filesystem will have problems

2) does that error happen when you start a new game, after you load a saved game or in both cases?
two additional questions:
1) what is your complete filepath, from drive letter to index.html?
Something like c:\folder\folder\folder\project\index.html
because if that filepath doesn't follow networking rules, the filesystem will have problems

2) does that error happen when you start a new game, after you load a saved game or in both cases?

1) C:\Users\HP\Desktop\DEMO\Pluzzed Souls Final

2) Only when I load the game saved with the script call
So you get the error when you try to save using the script call, or when you try to load a game that was saved using the script call?

Got that console log screenshot?
1) C:\Users\HP\Desktop\DEMO\Pluzzed Souls Final
Spaces are not allowed under networking rules, please rempve them from your folder name.
You can rename it Pluzzed_Souls_Final or something like that.

For more help we'll need a screenshot of the console output when the error happens.

Original thread: https://forums.rpgmakerweb.com/threads/save-command-not-working.112564/