Need some help with global variables

Hello there,

I have been working on a Monster Rancher plugin for MV but I wanted some values to be saveable and loadable. I tried to make a new global variable for the must save values but I have not found any working way of doing this. Here is my latest attempt:

Code:
let gameSystemInitialize = (function(){
    let _GS_init = Game_System.prototype.initialize;
    Game_System.prototype.initialize = (function(){
        _GS_init.call(this);

        this._energy = 0
        Game_System.prototype.energy = (function() {
        return this._energy;
        })
    })
})();

No matter what I do energy will return NaN instead of 0 while a nigh identical default one, winCount will return 0 as expected.
Maybe you could try this instead?
JavaScript:
(function(){
    
    let _GS_init = Game_System.prototype.initialize;
    Game_System.prototype.initialize = function(){
        _GS_init.call(this);
        this._energy = 0;
    };
    
    Game_System.prototype.energy = function(){
        return this._energy;
    };

})();

Original thread: https://forums.rpgmakerweb.com/threads/need-some-help-with-global-variables.124422/