How do I use an event dispatcher so I can use a widget button in another actor?

So I’m trying to make it where if I click a button, it destroys an actor. To do that I made it so if I click on the actor, it sets a canvas panel visible(which is in a widget blueprint), and in it there’s a button that I want to make it so if I click it, it destroys the actor. Everything works fine except for the button destroying the actor. I made a event dispatch for the “on clicked” in the widget :

and called it in the actor I want to destroy:

I’m making a city builder so there’s going to be multiple of the same buildings, that’s why I just left the “destroy actor” target to self, so it destroys itself instead of everyone of those buildings. If this is any help, this was the error message:

Any help would be greatly appreciated.

1 Like

The “Bind Event to Destroy Actor” fails because the Hud is not valid at the moment the “Event BeginPlay” triggers. Therefore the binding does not get assigned.

1 solution would be to play a delay and then assign the event. (In your case of cause use the destroy event not the visibilitevent).

Or you create a custom event in you actor which gets called from the widget once it is constructed.

It worked, thanks.