These should be created dynamically. If the player changes the menu now, “old buttons” should be used again and only new ones should be created if the old ones are not sufficient. At the same time it should be checked if this menu needs less buttons and the surplus should be deleted if necessary.
Unfortunately it does not work at all as expected… I have attached a photo and hope for your help.
You can create a widget with a button and a text for example, and save it as My_BTN widget.
In your widget now you can create instance of this “User created widget”
Create a function to update the number of My_BTN inside your widget.
Create an array to store the number and the reference and spawn a number of My_BTN ( lets say 10 ?)
When you "update " you give the function the new number of buttons you want. (Lets say 4?)
Loop for all the old array, “remove from parent” the buttons you dont need, or spawn more if you need, Set the reference again to the new.