MV Script Call to Unequip Weapon?

Hi, I'm trying to make it so that when a weapon is equipped into the Main Hand slot (.equips()[0]), the weapon in the Off Hand slot (.equips()[1]) gets unequipped. Is this possible?
"Replace actor 1's equip type 2 (off-hand slot) with item 0 (empty)":
JavaScript:
$gameActors.actor(1).changeEquipById(2, 0);
I assume you already have a way to run this kind of code at the appropriate time?
Sweet! Tyvm!!😂
"Replace actor 1's equip type 2 (off-hand slot) with item 0 (empty)":
JavaScript:
$gameActors.actor(1).changeEquipById(2, 0);
I assume you already have a way to run this kind of code at the appropriate time?
Thank you very much, how do I do when I click on the button the shield appears and when I release the button the character unequips the shield? I don't know, help me

@PauloWanderson, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.

This is also a thread hijack: your question (how to structure an event) is different from that of the original poster (a script call to perform a specific action). You're not in trouble, but try to avoid these things in future. 👋

You can do Conditional Branch -> Button is pressed every X frames, and use a switch to track whether the item is equipped or not. If you want more help, you can start a new thread:

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/script-call-to-unequip-weapon.139077/