Is there a way to instantly delete an equipped item?

I have a situation in which I am giving players a random equipped item, but I do not want them to keep those equipped weapons and armor after the sequence of events is over. I cannot keep track of which random items they get.

Let's say we're talking about a helmet; the way I think it works in MZ is that you have to unequip a player's head slot, add a new item to the inventory, then force equip the new random helmet. However, if there is a way to simply delete the equipped item before removing it (or as it is currently being removed), that would make it so I would not have to keep track of which items the player gets during the event sequence.

I'm not sure how else to get this done. I hope I explained it thoroughly enough to be understood. Thank you for your time.
I'm not sure I completely follow...
And, I'm not sure if this has changed in MZ, though I doubt it.
There is an event command to change player equipment/gear. When selecting this event command, you can tell it to use player equipped items or not, and specific to increase or decrease the gear. So that can handle equipping and unequipping the items.

There is, I believe a script to save/restore the player's current inventory, and another script to delete the entire inventory (or gear), so if you found those scripts or someone shared them, you could just: first run the script to save the current inventory state, then run the script to delete the inventory, then run the script to restore the inventory after the event would be the most painless way.

But I have a similar situation in my game, and instead, I just assign the equipment to variables. You can use variable controls and set the value of variables based on items/equipment owned.
So before the event, run a check to check what items the player currently has and assign them to those variables.
Next, run an event command to delete every item from the inventory.
Let that game sequence play out, and then at the end, run an event to check the variables and if it's more than 0, restore that number of item(s) to the player's inventory.
You can also use the push.scene script afterwards to push the equipment screen to remind players, "hey, please re-equip your old gear."
This is definitely a tedious way of doing it, and if you game has A TON of equipment, it may not be ideal. But assuming you aren't constantly checking this information, running it once is fine. It's just the set up that takes a little bit of time to do.
Try this in a Script command:
JavaScript:
const actor = $gameParty.members()[0];  // party leader
const slotId = 0;                       // first equip slot
// empty that slot (discard current item)
actor.forceChangeEquip(slotId, null);
Replace the actor and slotId values as appropriate.
I cannot keep track of which random items they get.
why not?

OK, depending on the way you randomize it might be tricky to store the resulting numbers in a variable, but it would be much easier for a lot of game mechanics if you do store the values...
Wow, there's a lot to unpack. When I post these questions, I'm sorry that I don't give all the details of everything I've tried because I figure it's best just to let you guys talk from your perspective, and I can learn from that.

First, thank you for all the comments, and for the scripts. That's phenomenal. I definitely want to try that out.

Second, I am going to be needing a complete save and reload of gear and items for one sequence I have prepared for later in my game's development, and I don't know how to do that. I had considered using it for my game's current sequence, but it seemed a bit extensive, so instead, I chose to lock access to the Items and Equip menu options, and simply handle the player's choice of gear through scripted choices.

Third... I understand what was said about using the variables, however, it might be a bit too complicated when I'm dealing with random items, which I need for the purpose of the combat mini-game I'm doing. Part of the reason for this is because I want to re-use this mini-game in a more randomized format later for challenges and rewards. It is true, that it is possible to do that; I can see that now, but I think I might try @caethyril 's script first because, if that works, it could save a great deal of time and processing.

It is a shame that MZ does not have any basic features to make variables strings or game items (auto-directed to their assigned integer). I'll just keep working around it.
It is a shame that MZ does not have any basic features to make variables strings or game items (auto-directed to their assigned integer). I'll just keep working around it.
But you can make any variable into a string variable - and have been able to do that for several makers, at minimum since VXAce.
It just requires the script line to assign the string directly.

and the same is true for game items and ID's if you know the commands
In case it helps, the MV / MZ Script Call List also documents ways to save/restore the party inventory or member equips in variables: Memorise Inventory, Restore Inventory, Memorise Equipment, Restore Equipment. Like Andar says, it's possible, even if it's not a "basic" feature.
In case it helps, the MV / MZ Script Call List also documents ways to save/restore the party inventory or member equips in variables: Memorise Inventory, Restore Inventory, Memorise Equipment, Restore Equipment. Like Andar says, it's possible, even if it's not a "basic" feature.
Thanks for that advice. I will look into that because I am seeing more and more that I need to script that feature into my game.

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-instantly-delete-an-equipped-item.162587/