How to make it so that when I press the G button, will my character throw away the weapon he is holding?

Сould you show me the details
this is to realize. I can imagine in my head how it should look, but I do not know how to do it exactly.