You can store state data in an array of structures and call the last item in the array to undo.
Create a button widget and add an event dispatcher.
Create a structure where you will store data for undo
Create a structure where you will store data for undo.
Add an array variable of the structures to your blueprint.
Call the button widget and subscribe to the click.
I have described the most straightforward way. However, you can build a more complex undo-redo system. Look at this post: UE4-21 UNDO in realtime - #2 by Supremative
Also, I’ve built a complex history system in my Runtime Editor: