Cannot destroy an actor from another actor.

I have an actor and when I click on it, it adds a UMG to the viewport.
On the UMG there is a button, which suppose to spawn an actor and destroy the previous one.(the previous = the one who added the UMG to viewport;)
Now … the UMG can spawn the new actor, but cannot destroy the previous one.
I tried to add a variable and cast and tried to destroy actor and destroy component and to make a function that destroys the actor.
none of that worked.
and for some reason, when I click on the previous acotr which suppose to be destroyed (Clicking on it through the UMG’ graph)
it says I cannot edit the default values if it matters.

Hello,
I just did 2 tries : first a 3d widget to destroy another actor and to destroy itself. Then the same widget add to viewport and it destroyed other actor too. You may have not set the reference of the actor. (If you use a function, add an output with “self” and use it. Or do a get all actors to find your actor if you don’t have reference easy to set tour variable “actor”

in the ‘self’ pin, I connected the reference variable to the actor bp (the one I want to destroy)

The input pin of “destroy actor” is “target” if you speak of this one. And this is the reference you use which needs to be set before you use it. On “begin play” with a “get all actors” and “get” if you have only one or loop and use an integer variable to know the right one to destroy if you have more. Or if you have a function use the output to add a reference to the right actor in level by using “self” in the actor bp to pass the variable. You can too create a custom event in the blueprint you want to destroy and call this custom event in widget. But you’ll have to set your reference too.

Thank you so much !