# Inventory System Save System - One Object Spawns on Play After Being Destroyed

**URL:** <https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597>\
**Category:** Programming & Scripting\
**Tags:** inventory, inventory-system, unreal-engine, Blueprint, question\
**Created:** [January 6, 2025, 1:52pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597 "2025-01-06T13:52:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maximum.Dino](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maximum.Dino](https://forums.unrealengine.com/u/Maximum.Dino)\
**Post date:** [January 6, 2025, 1:52pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/1 "2025-01-06T13:52:49Z")

</div>

I’m following [Ryan Laley’s Inventory System Tutorial](https://www.youtube.com/playlist?list=PL4G2bSPE_8umjCYXbq0v5IoV-Wi_WAxC3), and this is something I haven’t seen him cover, which is the fact that if I create a second type of object to collect in the inventory, the object being destroyed doesn’t save when I open the game again.  
So my question is, how do I get the second object to save after it’s destroyed and not reload in when I start the game up again? (the second object is the key and the first is the seashell. The seashell saves it’s destruction just fine.)

Code: [Library | Loom - 6 January 2025 | Loom](https://www.loom.com/share/748f1bf3c5e340d5a5e79ec8653d8a81?sid=376ab8bf-5411-4595-9845-c3a9793af05f)  
Gameplay: [Library | Loom - 6 January 2025 | Loom](https://www.loom.com/share/13015f04e01b4699a130ff6646735e46?sid=cf478840-1547-437f-bb7b-9c27fb22812e)

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [January 6, 2025, 2:27pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/2 "2025-01-06T14:27:42Z")

</div>

the key and the seashell should be a child of the same parent pickup actor?

if so it will work unless you’ve overwritten something in the child, for instance BeginPlay, make sure you Add Call To Parent Function

---

<div class="post-metadata">

**Author:** ![Maximum.Dino](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maximum.Dino](https://forums.unrealengine.com/u/Maximum.Dino)\
**Post date:** [January 6, 2025, 10:41pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/3 "2025-01-06T22:41:45Z")

</div>

Because I don’t want my players to be able to drop items, I skipped the part of the tutorial that lets you drop them (you may destroy them in your inventory instead) because of that I had to find a different way to do what he’s doing [here](https://youtu.be/97YiDYbbld0?feature=shared)

This is what I have instead for the code, it doesn’t work, I tried to adapt it to what I’m doing but its not working.

> **[Inventory System - Begin Play posted by anonymous | blueprintUE | PasteBin...](https://blueprintue.com/blueprint/phwvxg-z/)**
>
> No description provided

To my knowledge the key and seashell have the same parent and all and it calls the parent function on event begin play so… not sure why it isn’t working.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [January 7, 2025, 6:36am UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/4 "2025-01-07T06:36:35Z")

</div>

its hard to follow that without knowing the full context so a few thoughts

1. never use GetActorOfClass, you dont know what actor that will be
2. if you’re removing from inventory whats the map you’re adding too? if its a map of objects that have been picked up? if so then it should be on pickup not remove?

I assume this logic is in the PlayerPawn?

---

<div class="post-metadata">

**Author:** ![Maximum.Dino](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maximum.Dino](https://forums.unrealengine.com/u/Maximum.Dino)\
**Post date:** [January 7, 2025, 12:19pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/5 "2025-01-07T12:19:26Z")

</div>

Yeah, I figured using GetActorOfClass wasn’t the right move, I’m just really am not sure what to use. When they are destroyed, the item is destroyed [(demonstrated here)](https://www.loom.com/share/896d043e05104cb3af6ee228ef8c5c1a?sid=d92f3335-3683-4dfa-aa98-b281ce8732e6)

And [here’s the code](https://blueprintue.com/blueprint/eoma6ocu/) for remove inventory (although I don’t think it’s related to the problem, I could be incorrect. I fully followed the tutorial for this part though)

The logic is in an actor component I’ve created based on the tutorial, the bulk of the logic for the entire system are made up of different functions inside the component.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [January 8, 2025, 1:14am UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/6 "2025-01-08T01:14:11Z")

</div>

but your issue is the item in the world spawns when it shouldn’t?

show me the logic of where you handle that

---

<div class="post-metadata">

**Author:** ![Maximum.Dino](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maximum.Dino](https://forums.unrealengine.com/u/Maximum.Dino)\
**Post date:** [January 8, 2025, 12:23pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/7 "2025-01-08T12:23:42Z")

</div>

[This is the logic](https://blueprintue.com/blueprint/4m3ibs6j/) that’s meant to save the removal of the key from the world.  
It works on my seashell items, but not the key item.  
And [this is the logic](https://blueprintue.com/blueprint/6lff5mhb/) that happens when the game is started up again and is told not to spawn the objects that have been picked up.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [January 9, 2025, 2:11am UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/8 "2025-01-09T02:11:09Z")

</div>

your logic looks fine,

it seems the only relevant detail is the ActorsRemoved Array

so on pickup make sure its added to the array with a PrintString

and on your destroy loop print the names of the objects being destroyed

---

<div class="post-metadata">

**Author:** ![Maximum.Dino](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maximum.Dino](https://forums.unrealengine.com/u/Maximum.Dino)\
**Post date:** [January 10, 2025, 4:05pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/9 "2025-01-10T16:05:40Z")

</div>

I tried my best to follow these instructions, I don’t know if this is what you’re asking for but I tried:  
https://www.loom.com/embed/f5ae4fd118cd43f5a62bc2c6a78cbac1?sid=99735452-18a6-4214-944d-02d67faf4d13  
It looks like one of my seashells are also not destroying as they’re supposed to.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [January 11, 2025, 2:54am UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/10 "2025-01-11T02:54:36Z")

</div>

try a print after the IsValid check?

i’ve not used this system but you’re using soft object references? my understanding is there is no guarantee the objects would have the same object reference the next time you load, meaning the value wont pass the IsValid check?

if so i’m surprised Ryan used this method, but i could be wrong

---

<div class="post-metadata">

**Author:** ![doctorpepperdan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@doctorpepperdan](https://forums.unrealengine.com/u/doctorpepperdan)\
**Post date:** [January 11, 2025, 3:20am UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/11 "2025-01-11T03:20:00Z")

</div>

I had this same issue, I think it ended up being that I needed to clear the map/array in the saved game before setting it from the inventory component

---

<div class="post-metadata">

**Author:** ![Maximum.Dino](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maximum.Dino](https://forums.unrealengine.com/u/Maximum.Dino)\
**Post date:** [January 14, 2025, 12:08pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/12 "2025-01-14T12:08:07Z")

</div>

The soft reference was what he used, I’m pretty sure [this](https://youtu.be/97YiDYbbld0?feature=shared&t=515) is the soft object ref you’re referring to.

And here’s the string after IsValid?  
https://www.loom.com/embed/371316b01adc4215a680caf015153f09?sid=bf188796-1f19-4ec6-8955-d75125d0f5f1

---

<div class="post-metadata">

**Author:** ![Maximum.Dino](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maximum.Dino](https://forums.unrealengine.com/u/Maximum.Dino)\
**Post date:** [January 14, 2025, 12:08pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/13 "2025-01-14T12:08:46Z")

</div>

Do you have a visual example? If not that’s totally fine, I’m just wondering if you have a BP I can look at.

---

<div class="post-metadata">

**Author:** ![doctorpepperdan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@doctorpepperdan](https://forums.unrealengine.com/u/doctorpepperdan)\
**Post date:** [January 14, 2025, 8:29pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/14 "2025-01-14T20:29:29Z")

</div>

Yea I’ll post some screens tonight after work

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [January 15, 2025, 2:30am UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/15 "2025-01-15T02:30:12Z")

</div>

it looks correct so lets change focus, are you possibly adding/spawning a duplicate?

check the ActorsAdded map

---

<div class="post-metadata">

**Author:** ![Maximum.Dino](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maximum.Dino](https://forums.unrealengine.com/u/Maximum.Dino)\
**Post date:** [January 15, 2025, 12:23pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/16 "2025-01-15T12:23:22Z")

</div>

Here are all of the places that I use my actors added.

> **[Parent Item - Event Begin Play posted by anonymous | blueprintUE | PasteBin...](https://blueprintue.com/blueprint/h29b-arm/)**
>
> No description provided

Actually, for the [game mode begin play](https://blueprintue.com/blueprint/aylnc2wu/), when I remove everything after the complete loop (so actors added ‘keys’ and onward) The issue seems to be resolved, but in the future, I may want to utilize the add actors array, and I don’t know if this is a sustainable solution.

For [this one](https://blueprintue.com/blueprint/eqj5x0-_/), it’s odd because I don’t want the actors added to the scene so I’ve skipped past that step, but I’m not sure if I am doing that wrong. Not sure if related though at all. This is the only area place I would have added anything to the Add Actors array though.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [January 15, 2025, 2:20pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/17 "2025-01-15T14:20:05Z")

</div>

aha so we finally found it,

you can search you’re entire project to see if there is an ActorsAdded somewhere else, this is also a good lesson on why you should encapsulate that logic in functions.

but also if you ever Add an actor you must remember to remove it on pickup/destroy

---

<div class="post-metadata">

**Author:** ![Maximum.Dino](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maximum.Dino](https://forums.unrealengine.com/u/Maximum.Dino)\
**Post date:** [January 22, 2025, 7:04pm UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/18 "2025-01-22T19:04:24Z")

</div>

So the blueprints above are ALL the places I put the ActorsAdded array, so I’m unsure what I’d be searching for. I am having trouble understanding what is the course of action at this point in fixing this issue, I’m sorry

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [January 23, 2025, 12:23am UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/19 "2025-01-23T00:23:19Z")

</div>

so whats happening is your destroy function is working as intended but you’re spawning a duplicate on ActorsAdded.

we know this because when you Remove ActorsAdded it works.

the only place you have ActorsAdded is on Inventory Remove, which makes no sense because you said you dont want to drop items?

at this point in your project is there any reason to have ActorsAdded at all?

---

<div class="post-metadata">

**Author:** ![Maximum.Dino](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maximum.Dino](https://forums.unrealengine.com/u/Maximum.Dino)\
**Post date:** [January 24, 2025, 1:37am UTC](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597/20 "2025-01-24T01:37:29Z")

</div>

Oh, I see- my apologies for not understanding at first.  
So right now I do not have a use for actors added, though I will need it if further in the game an item spawns for the player to pick up. When I remove all parts of the code for actors added, specifically in the Event Begin Play on my game mode, it seems to work accordingly. I don’t know how to fix it so in the future I’d be able to add actors without unwanted actors spawning, though.  
I’ve also removed the actorsAdded from InventoryRemove but it doesn’t seem to have any effect.

[Next page](https://forums.unrealengine.com/t/inventory-system-save-system-one-object-spawns-on-play-after-being-destroyed/2262597.md?page=2)
