MV I need help to make a Skil to tranfer certain states

How could I make an ability that transfers only
the states belonging to a category from the user to the target.
I tried this but nothing happened, could you check it out?

transferStates = [];
for (i = 0; i < user.states().length; i++) {
if (user.states().category.contains('AILMENT')){
transferStates.push(user.states().id)
target.addState(transferStates);
user.removeState(transferStates);
}
}
I do not know enough java to help you there but I can suggest you this plugin that can do what you want !
@Boonty Please do not post full plugins but rather link to where the author has the plugin for download.
@Boonty Please do not post full plugins but rather link to where the author has the plugin for download.
I would have done it without problem but the original link for downloading it is dead
@Boonty it doesn't matter if the link is dead. You should not attach any plugins without the plugin author's permission.

@STARFALL I suggest trying the YEP Tips and Tricks, Absorb Ailments, but you need the corresponding plugins. Swap the user and target in the script and you are good to go.
Ok this problem is solved, you just had to insert it in the right place. Thank you all for your attention and help. Here is the final result in case you want to use it.


Code:
<After Eval>
transferStates = [];
for (i = 0; i < user.states().length; i++) {
    if (user.states()[i].category.contains('AILMENT')){
        transferStates.push(user.states()[i].id)
        target.addState(transferStates[i]);
        user.removeState(transferStates[i]);
    }
}
</After Eval>
Thanks a lot for your share. I will use a modified version for my project

Original thread: https://forums.rpgmakerweb.com/threads/i-need-help-to-make-a-skil-to-tranfer-certain-states.130879/