Am I using this script command correctly?

Basically, I am just trying to increase the stats of a specific troops magic defense by a variable I just want to know if I am coding this correctly:

$gameTroop.members().addparam(5, $gameVariables[26]) is the script I'm using to change the magic defense of troop #1 by variable 25
This will not work the way you've written it, i'm also not sure if you actually mean the 2nd member of the troop instead of all the troop members.

You also mention variable 25, but your code is trying to reference variable 26, make sure you use the correct variable.

JavaScript:
// If you want to buff the 2nd member in the troop
$gameTroop.members()[1].addParam(5, $gameVariables.value(26));

// If you want to buff all members in the troop
$gameTroop.members().forEach(member => member.addParam(5, $gameVariables.value(26)));
Your question is a little hard to understand - you seem to be mixing up the terminology between "Troop" and "Enemy."

Aside from that, and what Toby already pointed out, you also have the wrong syntax for the variable. There's no such thing as $gameVariables[26] - where did you find that syntax?

The value of a variable is $gameVariables.value(26)
What both of them are trying to tell you is that $gameVariables per se is NOT an array, thus you can't access its data via an array's index [1] as you first intended.
The same principle is valid for $gameSwitches.
How do you access the values then? TobyYasha already took care of that.
This will not work the way you've written it, i'm also not sure if you actually mean the 2nd member of the troop instead of all the troop members.

You also mention variable 25, but your code is trying to reference variable 26, make sure you use the correct variable.

JavaScript:
// If you want to buff the 2nd member in the troop
$gameTroop.members()[1].addParam(5, $gameVariables.value(26));

// If you want to buff all members in the troop
$gameTroop.members().forEach(member => member.addParam(5, $gameVariables.value(26)));
I attempted to put this in the troops scripts but the stats didnt change I placed it like in the image have i put it in the wrong spot?
1709852712143.png
The problem is that you didn't change the "Don't Run" condition, meaning nothing gets executed.
You should change it to something like "Turn 0" or any other condition that you see fit.
The problem is that you didn't change the "Don't Run" condition, meaning nothing gets executed.
You should change it to something like "Turn 0" or any other condition that you see fit.
Oh. thats works perfectly, thank you for all the help!

Original thread: https://forums.rpgmakerweb.com/threads/am-i-using-this-script-command-correctly.166565/