BackButton in script based menu

I made a table, and every of those are buttons. I want to make a back button that recovers the last set of buttons that were showed before the current ones using another table, but I reallly need help for that. What I did for now is, i did a table.insert that puts the button clicked in the table with its sub buttons. But first of all, I can’t even get the other buttons that were with the button clicked as I only stored that button. And second of all, I don’t know how to tell my script where I am using the button names. I dont think thats clear but idk how to explain it