How do I save an actor as a variable in game and then spawn it in a new location?

I’m a bit newish to the C++ side of Unreal, but I’m trying to expand my knowledge on it a bit. What I’m trying to do is have an actor that is hit by a line trace be “copied” and destroyed, and then on the next shot place a copy of the actor that was originally destroyed. I’m also wanting to make it so that a second actor can’t be copied/destroyed until the first actor has been placed. Essentially you can only “carry” one actor at a time and must set it down before picking up a second. I’m using the default C++ First Person Template and here’s what I have so far:

The ActorStored variable begins the game as false. When it is false and the line trace hits an actor, the actor’s name is displayed on the screen (for testing), the actor is destroyed, and ActorStored is set to true. While ActorStored is set to true, nothing will happen if another actor is hit with the line trace. After the first miss by the line trace, ActorStored is set to false so the cycle can begin again.

What I want to have happen is when the line trace hits the first actor, a copy of that actor is saved to a variable before it is destroyed. Then when the line trace doesn’t hit anything, it would place a copy of the saved actor at the end point of the line trace.

What I think I need is a variable for the actor (AActor I think in C++?), and then code to spawn that actor at the end point of the line trace when it misses. Alternatively, I think it might also work to spawn the actor at the impact point on a hit, but I’m unsure which is easier. I’ve tried messing around with both, but I couldn’t get either to work.

Here’s a copy of the code I have so far. It’s in the OnFire function in the First Person character class.