MZ [MZ]TypeError: Cannot read property 'members' of undefined?

Hey Guys, Im getting this error everytime when the battle ends.
I clear all troops and tried again, but the error continues, can anyone help me?
rmmz_managers.js:1970 TypeError: Cannot read property 'members' of undefined
at Game_Troop.setup (rmmz_objects.js:5906)
at Game_Troop.<computed>.<computed> (VisuMZ_0_CoreEngine.js:7565)
at Game_Troop.<computed>.<computed> [as setup] (VisuMZ_1_BattleCore.js:16299)
at Function.BattleManager.setup (rmmz_managers.js:2232)
at Socket.<anonymous> (MMO_Core_Party_Combat.js:97)
at Socket.Emitter.emit (index.mjs:136)
at Socket.emitEvent (socket.js:498)
at Socket.onevent (socket.js:485)
at Socket.onpacket (socket.js:455)
at Manager.Emitter.emit (index.mjs:136)





Game_Troop.prototype.setup = function(troopId) {
this.clear();
this._troopId = troopId;
this._enemies = [];
for (const member of this.troop().members) {
if ($dataEnemies[member.enemyId]) {
const enemyId = member.enemyId;
const x = member.x;
const y = member.y;
const enemy = new Game_Enemy(enemyId, x, y);
if (member.hidden) {
enemy.hide();
}
this._enemies.push(enemy);
Try this.members() instead of "this.troop().members".

I've moved this thread to Plugin Support (from MZ Support). Thank you.

Looks like the plugin "MMO_Core_Party_Combat" is starting a battle based on a troop that has no database record. To fix it, you need to make sure the appropriate troop (whichever one it is) is defined in the database.

If you want help with a plugin, I suggest you link to the plugin's page.

Edit @Aerosys: I do not think this.members() will work here, because that references the troop's _enemies, which is what the setup method populates.
Edit @Aerosys: I do not think this.members() will work here, because that references the troop's _enemies, which is what the setup method populates.
That might be true.

OP, I guess your code snippet is broken because it has more opening brackets than closing ones. That confused me.

Original thread: https://forums.rpgmakerweb.com/threads/mz-typeerror-cannot-read-property-members-of-undefined.158836/