VexCODE Custom Menu Not Working

So recently I’ve been attempting to make a menu with a GIF playing in the background, which works all fine and dandy, but when I try to select any of the menu options, it just freezes the entire thing. Can anyone help me out and let me know what I’m doing wrong? I’m not very experienced with GIFs so I’m sure I’m making a huge mistake somewhere in the code.
Here’s the code I used:

  int titleBGRand, displayX, displayY, buttonLRSP = 1;
  std::string titleBG;

  Brain.Screen.setPenColor("#A1A1A1");
  Brain.Screen.setFont(prop60);

  for (int count = 0; count < 300; count++)
  {
    Brain.Screen.printAt(count-200,50,"Main");
    Brain.Screen.printAt(540-count,50,"Menu");
    task::sleep(5);
  }

  Brain.Screen.setFont(mono30);
  Brain.Screen.printAt(180,100,"Press A");

  while (!Controller1.ButtonA.pressing())
  {
    task::sleep(10);
  }
  while (Controller1.ButtonA.pressing())
  {
    task::sleep(10); 
  }
  
  Brain.Screen.clearScreen();
  Brain.Screen.setFont(prop60);
  Brain.Screen.printAt(99,50,"Main");
  Brain.Screen.printAt(241,50,"Menu");

  srand(timer::system());
  titleBGRand = rand() % 3 + 1;
  if (titleBGRand == 1)
  {
    titleBG = "marioBG_copy.gif";
    displayX = 100;
    displayY = 0;
  }
  else if (titleBGRand == 2)
  {
    titleBG = "minecraftBG.gif";
    displayX = 20;
    displayY = 0;
  }
  else
  {
    titleBG = "shrek_speed.gif";
    displayX = 18;
    displayY = 1;
  }
  vex::Gif gif(titleBG.c_str(),displayX,displayY);
  Brain.Screen.setFillColor(transparent);
  while (!Controller1.ButtonA.pressing())
  {
    Brain.Screen.render();
    task::sleep(10);

    Brain.Screen.setFont(prop60);
    Brain.Screen.setPenColor("#A1A1A1");
    Brain.Screen.printAt(99,50,"Main");
    Brain.Screen.printAt(241,50,"Menu");

    if (menuSel == 1)
      Brain.Screen.setPenColor(blue);
    else
      Brain.Screen.setPenColor(white);
    Brain.Screen.drawRectangle(50,100,100,100);
    if (menuSel == 2)
      Brain.Screen.setPenColor(blue);
    else
      Brain.Screen.setPenColor(white);
    Brain.Screen.drawRectangle(190,100,100,100);
    if (menuSel == 3)
      Brain.Screen.setPenColor(blue);
    else
      Brain.Screen.setPenColor(white);
    Brain.Screen.drawRectangle(330,100,100,100);

    Brain.Screen.setPenColor(white);
    Brain.Screen.setFont(mono30);
    Brain.Screen.printAt(70,150,"PLAY");
    Brain.Screen.printAt(210,150,"EDIT");
    Brain.Screen.printAt(340,150,"EXTRA");

    if (Controller1.ButtonRight.pressing() && !Controller1.ButtonLeft.pressing() && buttonLRSP == 1)
    {
      menuSel++;
      buttonLRSP = 0;
    }
    else if (Controller1.ButtonLeft.pressing() && buttonLRSP == 1)
    {
      menuSel--;
      buttonLRSP = 0;
    }
    else if (notPressing())
      buttonLRSP = 1;

    if (menuSel > 3)
      menuSel = 1;
    else if (menuSel < 1)
      menuSel = 3;
  }
  Brain.Screen.print("Yes");
  Brain.Screen.clearScreen();