How to check for enemy index

Hi!! I wanted to add a check when a certain skill is used to see if the Enemy Index number is X, then do something.

Im trying this to Check for first enemy in the troop. Of course it doesn't work =P

Code:
if (target.$gameTroop.members()[0]) {
var text = '<CENTER>' + 'It goes through';
SceneManager._scene._logWindow.push('addText', text);
}

Any help? Thanks!!
if (target.$gameTroop.members()[0])

That line, assuming you're checking the target of the skill, should be this:

if (target === $gameTroop.members()[0])
Ha ha OMG, I need to rest a bit, how on earth I was trying to check something without the operator? Thanks man.
Can you help me on something else? its really simple, when the above condition is met, I want a variable to be up by one every time, like a counter.

Im using $gameVariables.value(X) += 1 Of course it doesnt work.
Using value simply checks the value; it can't be changed that way. To change it requires something like this:

$gameVariables.setValue(X, $gameVariables.value(X) + 1)

Strange as it sounds, adding to the variable doesn't have its own function. It has to be done with setValue. The first number is which variable to change, while the second is what to change it to, in this case, the current value + 1.
Ok, I understand it pretty well.

Thank you!!!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-for-enemy-index.86852/