RPG Maker MV Invalid or Unexpected token.

Hello,

I just found a script online for a Party renaming from a party list, and when I use it shows the Invalid token error, this is the script I am using:

Script: var findId = $gameParty._actors; var idLen = findId.length; var findId2 = []; for (e = 0; e < idLen; e++) {findId2[e] = findId[e];} var ee = 0; choices = []; params = []; $gameMessage.setChoices(choices, 0, -1) for (e = 0; e < idLen; e++) {choices.push(String($gameParty.members()[ee]._name)); ee++;} params.push() $gameMessage.setChoiceCallback(function(responseIndex) {SceneManager.push(Scene_Name); SceneManager.prepareNextScene(findId2[responseIndex], 8)})

Can someone help me, please? (I know very little about JS)

I've moved this thread to Plugin Support. Thank you.

There were some syntax errors.
Try this:
Code:
var findId = $gameParty._actors;
var idLen = findId.length;
var findId2 = [];
for (e = 0; e < idLen; e++) {
  findId2[e] = findId[e];
}
var ee = 0;
choices = [];
params = [];
$gameMessage.setChoices(choices, 0, -1);
for (e = 0; e < idLen; e++) {
  choices.push(String($gameParty.members()[ee]._name));
  ee++;
}
params.push();
$gameMessage.setChoiceCallback(function(responseIndex) {
  SceneManager.push(Scene_Name);
  SceneManager.prepareNextScene(findId2[responseIndex], 8);
})

And a tip: When you see unexpected token, quickly paste that code into https://esprima.org/demo/validate.html
It checks for syntax errors and tells you which part to fix.

Edit: Since script calls can't be more than 12 lines, here's a minified version:
Code:
var findId=$gameParty._actors;var idLen=findId.length;var findId2=[];for(e=0;e<idLen;e++){findId2[e]=findId[e];}
var ee=0;choices=[];params=[];$gameMessage.setChoices(choices,0,-1);for(e=0;e<idLen;e++){choices.push(String($gameParty.members()[ee]._name));ee++;}
params.push();$gameMessage.setChoiceCallback(function(responseIndex){SceneManager.push(Scene_Name);SceneManager.prepareNextScene(findId2[responseIndex],8);})
Try adding a semi-colon immediately after each of these parts:
Code:
$gameMessage.setChoices(choices, 0, -1)
Code:
params.push()
(@Hyouryuu-Na did you miss the first one?) [Edit: never mind, didn't see the edit. 😴]

You need a semi-colon at the end of each "line" of JS if you want to pack it all into one line. I pasted it into Visual Studio Code (free code editor) and the code "spell-checker" picked up on the missing semi-colons right away~ 🙏
Which one? I didn't even look at the code XD Just saw where there weren't any semi colons and added them there XD
There were some syntax errors.
Try this:
Code:
var findId = $gameParty._actors;
var idLen = findId.length;
var findId2 = [];
for (e = 0; e < idLen; e++) {
  findId2[e] = findId[e];
}
var ee = 0;
choices = [];
params = [];
$gameMessage.setChoices(choices, 0, -1);
for (e = 0; e < idLen; e++) {
  choices.push(String($gameParty.members()[ee]._name));
  ee++;
}
params.push();
$gameMessage.setChoiceCallback(function(responseIndex) {
  SceneManager.push(Scene_Name);
  SceneManager.prepareNextScene(findId2[responseIndex], 8);
})

And a tip: When you see unexpected token, quickly paste that code into https://esprima.org/demo/validate.html
It checks for syntax errors and tells you which part to fix.

Edit: Since script calls can't be more than 12 lines, here's a minified version:
Code:
var findId=$gameParty._actors;var idLen=findId.length;var findId2=[];for(e=0;e<idLen;e++){findId2[e]=findId[e];}
var ee=0;choices=[];params=[];$gameMessage.setChoices(choices,0,-1);for(e=0;e<idLen;e++){choices.push(String($gameParty.members()[ee]._name));ee++;}
params.push();$gameMessage.setChoiceCallback(function(responseIndex){SceneManager.push(Scene_Name);SceneManager.prepareNextScene(findId2[responseIndex],8);})
Thanks a lot, it worked like a charm! I'll make sure to credit you. 🙂
No no you don't need to credit me! I just put in two semi colons XD
But good to know it works for you now.

Original thread: https://forums.rpgmakerweb.com/threads/rpg-maker-mv-invalid-or-unexpected-token.126847/