How can I have a basic inventory system and spawn an item when I call a function?

Tom Looman has done an amazing job with a basic inventory system tutorial that implements “usable actors” to manage inventory. I strongly suggest you go through it.

Hope this helps you as much as it helped me.