Wait for user input

Hello, I am making a simple arduino game with push buttons and LEDs. However, I need the game to wait to start until a difficulty is selected by touching a certain box on a touchscreen TFT. The game always starts before it receives the difficulty input. What are some ways I can have it wait until it recieves input? I’ve tried a do while loop that does nothing until a button is clicked. Should i have the difficulty button function in setup or loop? Here’s my code if anyones curious about the specifics.

//void touch() is the custom difficulty button function
void touch(){
  TSPoint p = ts.getPoint();
  if (currentPage == '0'){
   button = false;

  if (p.z > ts.pressureThreshhold) {
    
   p.x = map(p.x, TS_MAXX, TS_MINX, 0, 320);
   p.y = map(p.y, TS_MAXY, TS_MINY, 0, 480);
    pinMode(XM, OUTPUT);
    pinMode(YP, OUTPUT);

   
   if(p.x>=10 && p.x<=170 && p.y>=120 && p.y<=190){
    diff = "EASY";
    x=10000;
    //PLAYER_WAIT_TIME = 5000; use this with Ryans Uno
    currentPage = '1';
    drawScore();
    button = true;
  }
   
   if(p.x>10 && p.x<155 && p.y>165 && p.y<240){
    diff = "MEDIUM";
    x=7500;
    //PLAYER_WAIT_TIME = 3000;
    currentPage = '1';
    drawScore();
        button = true;

   }
   
   if(p.x>250 && p.x<390 && p.y>140 && p.y<300){
    diff = "HARD";
    x=5000;
    //PLAYER_WAIT_TIME = 1000;
    currentPage = '1';
    drawScore();
        button = true;

    }
  }
 }
}

///
/// Where the magic happens
///
void loop() {  
  touch();
  TSPoint p = ts.getPoint();
  //ADD IN BUTTON & WAIT IN LOOP AND TOUCH();
  while (button = false){}
  if(!wait){ //this is where the game starts playing now
That snippet suggests you have a function called "touch" which sets the difficulty, and a flag called "button" which indicates whether this difficulty has been set (very descriptive and easy to associate names, don't you think?"). That's at least my best guess.

Based on that, it's simple to have your code wait for difficulty to be set:

setup() {
  button = false;
}

loop() {
  if (button) {
    doGameRoutine();
  else {
    touch();
  }
}

The Loop you added to wait until a button is pressed was a step in the right direction. You just did it wrong.

You Loop: while (button = false){} There is no way button will ever Change within the Loop!!!!!

replace the touch() call at the top of Loop with while (button = false){touch();}

remove the Loop you added while (button = false){}.

This way, the Loop runs, allowing button to be set to true, until button is set to true.

tutorials and function reference are, as usual, just a quick Google search away...