Button, gui, process bar please help

Hello, sorry for my bad English. I’m designing a game. I made a gui screen that opens when you press the button. And there is a machine that starts repairing when you press the button. My request is this: When the button is pressed, the gui screen will open showing where the process is, the machine will start repairing, when the gui screen is closed, it will stop the repair and the process will stop and stay in the same place (if left at 50%, when it runs, it will start repairing from 50% again)