I've seen people use the UndoRedo only in Plugins, I've tried using it for my game but it didn't update to the older values somewhy, I think I didn't understand it well although I tried...
Here's a brief of my code with some simplifications (read it like a pseudocode it's not actually my code I just didn't wanna spam you with alot of lines):
var undo_redo = UndoRedo.new()
undo_redo.add_undo_property(main_board, 'level', main_board.level)
main_board.level = main_board.to_string()
undo_redo.add_do_property(main_board, 'level', main_board.level)
if event.scancode == KEY_Z and Input.is_key_pressed(KEY_CONTROL):
I have the level property in the board object which I want to change back when you press ctrl + z, it changes from the mainboard.tostring(), to visually update my board I use the updateboardfrom_string() so it's not really important in this case
It all seems to be working, the updatemainboard function is called, the versions are looking good but the level property doesn't change when I press ctrl + z, it prints the same one.
Here's an example of the debug console when I do 12 moves then press ctrl + z multiple times:
As you can see the level changes before doing the ctrl + z's (the 10th and 12th characters switch) and when I undo it doesn't change to what it was