Side-Quest / Item check

Hello, I have an issue regarding something quite common for a side quest:

This side quest involves collecting 5 units of an item. The quest is completed only when you reach 5 units.
How can I make it work if the item is dropped by an enemy?
Additionally, there is another small problem. If the player collects 5 or more units of this item, they can choose whether or not to give them to the NPC. For example, if the player decides to sell all the units, the count should be reset to 0.

Of course, I've considered using a variable, but how can I link it to the corresponding enemy drop and also account for the possibility of the item being sold?
How can I make it work if the item is dropped by an enemy?
I'm not sure what you're asking. Whether you get an item from an enemy drop, a chest, or buy it from a store, it's still in the party's inventory.

Any time you like, you can do Control Variables -> Game Data -> Item to see how many of that item the party has.

Additionally, there is another small problem. If the player collects 5 or more units of this item, they can choose whether or not to give them to the NPC. For example, if the player decides to sell all the spines, the count should be reset to 0.
So you'd do Change Items -> Decrease -> Variable -> the variable you got above with how many they own. Now they own 0.
Any time you like, you can do Control Variables -> Game Data -> Item to see how many of that item the party has.

I can second what ATT_Turan said. Also, I kinda explain how to use variables in my tutorial game (Learn RPG Maker MV from my signature).

You collect the items normally, whatever way you want. Them, you can create a new page that checks if the person has this item. If you want to check an amount, you go for a Conditional Branch with the said variable method to check the game data.
Thank you guys I'll try and let you know!

EDIT:

Yes, it worked, thank you!

Original thread: https://forums.rpgmakerweb.com/threads/side-quest-item-check.158645/