Skill not working.

Heyyyy. So IDK if this is really the right place to put this but it does involve a plugin so I think it counts? anyways, I have this skill called "observe" It works like Undertale's check command, or Paper Mario's tattle mechanic. the problem I'm experiencing is that no matter what I do my skill will only give me the description of the enemy "Spider" (enemy ID #2). IDK why this is happening and nothing I do will fix it. If you a solution please tell me! it would be greatly appreciated. There are some screen shots below for those needing more information. Also, some more information for y'all. the variable "Enemy ID" is #6, which is why the javascript code has a 6 in the parenthesis. The javascript code and the basic function of it was based off of SRDude's "Act + Mercy" system video. so here it is if you think it will help solve the problem.

Edit 1: after doing some testing i've realized that it's not giving me just the description of enemy 2, the spider. Instead it's giving me the description of the first enemy that the skill was used on in that particular save file. In my test file the first enemy was enemy #1 "enemytest" and when I used the skill on a different enemy it used it's description. Hope this helps.

Edit 2: after thinking for a bit I think i know the reason(s) why it's not working (sadly idk a solution but maybe after some rest I can think of one). So, I have 2 theories, 1st is that something is wrong with the javascript and that's why it's not working, however this is unlikely since it worked when first used, 2nd is that something is wrong with skill core, specifically it not running before eval or after eval. this would make sense as it would explain why the code that Shockra provided me didn't work, however the fact that it worked the first time still puzzles me.

Edit 3:It's fixed! yaaaaaay! I would like to thank Shockra for helping me so much, without him i probably would never have found the problem.
A possible issue is that I think the Common Event is set before the variable is changed. I've tried something like this before, and what I would recommend is rather than setting the Common Event in the Effect window, put this code in the Before Eval:

<Before Eval>
$gameVariables.setValue(6, b.enemyId());
$gameTemp.reserveCommonEvent(CommonEventID#);
</Before Eval>

The way Common Events work in battle is that the event doesn't run exactly when the skill is used; it's stored in $gameTemp and ran after the action is finished. This code will ensure that the variable is changed the instant before the common event is called.

If this doesn't work, try using <After Eval> instead. Not sure if it matters, but it's what I used and it seemed to work.
A possible issue is that I think the Common Event is set before the variable is changed. I've tried something like this before, and what I would recommend is rather than setting the Common Event in the Effect window, put this code in the Before Eval:

<Before Eval>
$gameVariables.setValue(6, b.enemyId());
$gameTemp.reserveCommonEvent(CommonEventID#);
</Before Eval>

The way Common Events work in battle is that the event doesn't run exactly when the skill is used; it's stored in $gameTemp and ran after the action is finished. This code will ensure that the variable is changed the instant before the common event is called.

If this doesn't work, try using <After Eval> instead. Not sure if it matters, but it's what I used and it seemed to work.

Hey! thanks for responding, just a few questions that may sound dumb, do i replace "CommonEventId#" with the actual number or do i just replace the "#" or "ID#". I know that may sound dumb but I'm asking because now the common event doesn't even run on both before eval and after eval.
CommonEventID# is just 2, or whatever the Common Event ID is. No #. But it's possible that I overthought the answer. It's been awhile since I've tried this. If that doesn't work, it's possible that the IF/ELSE statements are distorting the logic somehow. I think I just used an IF statement for each ID without ELSE. With each IF statement checking the same variable, the ELSE part isn't entirely necessary.
CommonEventID# is just 2, or whatever the Common Event ID is. No #. But it's possible that I overthought the answer. It's been awhile since I've tried this. If that doesn't work, it's possible that the IF/ELSE statements are distorting the logic somehow. I think I just used an IF statement for each ID without ELSE. With each IF statement checking the same variable, the ELSE part isn't entirely necessary.
Hey, so just gonna let you know 2 things. 1. sadly both of your solutions haven't works, and 2. I've edited the main post with some new findings after testing the game some more. just thought i'd let you know.
The only thing I can think of is to try resetting the variable to 0 at the end of the Common Event. Also, the Common Event in the video doesn't use any ELSE statements, so maybe that's part of the problem?

Edit: It could also be a problem with the action sequence. What's the rest of it below what can be seen?
The only thing I can think of is to try resetting the variable to 0 at the end of the Common Event. Also, the Common Event in the video doesn't use any ELSE statements, so maybe that's part of the problem?

Edit: It could also be a problem with the action sequence. What's the rest of it below what can be seen?

Hey so after thinking for a bit I think i know the reason(s) why it's not working (sadly idk a solution but maybe after some rest I can think of one) So, i did change it from if else to just if, and it still didn't change anything, and after adding the reset to 0 at the end of it the skill doesn't display any text, this leads me to believe that the reason why it's not working is because the Variable isn't updating when the skill is used. and so I have 2 theories, 1st is that something is wrong with the javascript and that's why it's not working, however this is unlikely since it worked when first used, 2nd is that something is wrong with skill core, specifically it not running before eval or after eval. this would make sense as it would explain why the code you provided at first wouldn't work, however the fact that it worked the first time still puzzles me.
I have updated the original post so that new readers will know of this.
(also I added the action sequence code to the original post as well)
OK, so the action sequence as it sits now doesn't actually call the effect at all. This line is needed somewhere within the <target action>:

action effect

Without that line, the skill does nothing. The <Before Eval> isn't called, so the variable isn't affected, and the Common Event is based on the unchanged variable. I'm uncertain what set the variable initially, but this is the most likely issue.
OK, so the action sequence as it sits now doesn't actually call the effect at all. This line is needed somewhere within the <target action>:

action effect

Without that line, the skill does nothing. The <Before Eval> isn't called, so the variable isn't affected, and the Common Event is based on the unchanged variable. I'm uncertain what set the variable initially, but this is the most likely issue.

ok! i added that and it works now! i honestly didn't know that i need to insert action effect there. I thought it only made it so that the enemy would take damage or that the effects would go off. but i guess not lol. thanks!

Original thread: https://forums.rpgmakerweb.com/threads/skill-not-working.107650/