I have a code and I can't figure out whats wrong with it

So I’m getting two errors
function definition is not allowed here (116,24) referring to void userControl(void) { its highlighting the bracket {
function definition is not allowed here (193,12) referring to void userControl(void) { also referring to the { bracket.
I’m relatively new to coding and the only one who is “competent in coding” (I try my best) and for the life of me I just can’t figure out why and how to fix these errors.
Here’s the code:

#pragma region VEXcode Generated Robot Configuration
// Make sure all required headers are included.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>


#include "vex.h"

using namespace vex;

// Brain should be defined by default
brain Brain;


// START V5 MACROS
#define waitUntil(condition)                                                   \
  do {                                                                         \
    wait(5, msec);                                                             \
  } while (!(condition))

#define repeat(iterations)                                                     \
  for (int iterator = 0; iterator < iterations; iterator++)
// END V5 MACROS


// Robot configuration code.
digital_out DigitalOutA = digital_out(Brain.ThreeWirePort.A);
#pragma endregion VEXcode Generated Robot Configuration

// ----------------------------------------------------------------------------
//                                                                            
//    Project:                                               
//    Author:
//    Created:
//    Configuration:        
//                                                                            
// ----------------------------------------------------------------------------

// Include the V5 Library
#include "vex.h"

// Allows for easier use of the VEX Library
using namespace vex;

// Begin project code
// Create motor objects for the flywheel, drivetrain, and intake

vex::motor flywheel1 = vex::motor(vex::PORT11);
vex::motor flywheel2 = vex::motor(vex::PORT12);
vex::motor leftDrivefront = vex::motor(vex::PORT1);
vex::motor leftDriveback = vex::motor(vex::PORT2);
vex::motor rightDrivefront = vex::motor(vex::PORT9);
vex::motor rightDriveback = vex::motor(vex::PORT10);
vex::motor intake = vex::motor(vex::PORT5);
vex::motor shooterArmrotater = vex::motor(vex::PORT17);
vex::controller controller1 = vex::controller();
vex::pneumatics pneumatics1 = vex::pneumatics(Brain.ThreeWirePort.A);
vex::pneumatics pneumatics2 = vex::pneumatics(Brain.ThreeWirePort.B);
void preAutonomous(void) {
  // actions to do when the program starts
  Brain.Screen.clearScreen();
  Brain.Screen.print("pre auton code");
  wait(1, seconds);
  
  // Robot configuration code.

  
  controller Controller1 = controller(primary);
  
motor Motor2 = motor(PORT2, ratio6_1, false);


motor Motor1 = motor(PORT1, ratio6_1, true);


motor Motor9 = motor(PORT9, ratio6_1, true);


motor Motor10 = motor(PORT10, ratio6_1, false);


motor Motor11 = motor(PORT11, ratio6_1, false);


motor Motor12 = motor(PORT12, ratio6_1, true);


motor Motor5 = motor(PORT5, ratio6_1, false);


motor Motor21 = motor(PORT21, ratio6_1, false);


motor Motor17 = motor(PORT17, ratio6_1, false);




}

void autonomous(void) {
  Brain.Screen.clearScreen();
  Brain.Screen.print("autonomous code");
  // place automonous code here
}

void userControl(void) {{}
  Brain.Screen.clearScreen();
  // place driver control in this while loop
  while (true) {
    wait(20, msec);
    
void userControl(void) {
 
  
    // Print the RPMs and voltage of all motors
    Brain.Screen.clearScreen();
    Brain.Screen.print("flywheel1 RPM: %f", flywheel1.velocity(vex::velocityUnits::rpm));
    Brain.Screen.newLine();
    Brain.Screen.print("flywheel2 RPM: %f", flywheel2.velocity(vex::velocityUnits::rpm));
    Brain.Screen.newLine();
    Brain.Screen.print("Left Drivefront RPM: %f", leftDrivefront.velocity(vex::velocityUnits::rpm));
    Brain.Screen.newLine();
    Brain.Screen.print("Left Driveback RPM: %f", leftDriveback.velocity(vex::velocityUnits::rpm));
    Brain.Screen.newLine();
    Brain.Screen.print("Right Drivefront RPM: %f", rightDrivefront.velocity(vex::velocityUnits::rpm));
    Brain.Screen.newLine();
    Brain.Screen.print("Right Driveback RPM: %f", rightDriveback.velocity(vex::velocityUnits::rpm));
    Brain.Screen.newLine();
    Brain.Screen.print("Intake RPM: %f", intake.velocity(vex::velocityUnits::rpm));
    Brain.Screen.newLine();
    Brain.Screen.print("Flywheel1 Voltage: %f", flywheel1.power(vex::powerUnits::volt));
    Brain.Screen.newLine();
    Brain.Screen.print("Flywheel2 Voltage: %f", flywheel2.power(vex::powerUnits::volt));
    Brain.Screen.newLine();
    Brain.Screen.print("Left Drivefront Voltage: %f", leftDrivefront.power(vex::powerUnits::volt));
    Brain.Screen.newLine();
    Brain.Screen.print("Left Driveback Voltage: %f", leftDriveback.power(vex::powerUnits::volt));
    Brain.Screen.newLine();
    Brain.Screen.print("Left Driveback Voltage: %f", leftDriveback.power(vex::powerUnits::volt));
  
 
     while (true) {
   // Spin the flywheel at full speed when the X button is pressed
   if (controller1.ButtonX.pressing()) {
     flywheel1.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
     flywheel2.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
   } else {
     // Stop the flywheel when the X button is not pressed
     flywheel1.stop(vex::brakeType::coast);
     flywheel2.stop(vex::brakeType::coast);
   }
 
while (true) {
    // Set the left and right drive motors to the values of the left and right joysticks(reversed)
   if (controller1.ButtonA.pressing()) {
    leftDrivefront.spin(forward, (controller1.Axis3.value() + controller1.Axis1.value()),percent);
  leftDriveback.spin(forward, (controller1.Axis3.value() + controller1.Axis1.value()),percent);
  rightDrivefront.spin(forward, (controller1.Axis3.value() - controller1.Axis1.value()),percent);
  rightDriveback.spin(forward, (controller1.Axis3.value() - controller1.Axis1.value()),percent);
   } else {
      // Set the left and right drive motors to the values of the left and right joysticks(normal drivetrain)
     leftDrivefront.spin(reverse, (controller1.Axis3.value() + controller1.Axis1.value()),percent);
  leftDriveback.spin(reverse, (controller1.Axis3.value() + controller1.Axis1.value()),percent);
  rightDrivefront.spin(reverse, (controller1.Axis3.value() - controller1.Axis1.value()),percent);
  rightDriveback.spin(reverse, (controller1.Axis3.value() - controller1.Axis1.value()),percent);
   }




   // Spin the intake in when the R1 button is pressed
   if (controller1.ButtonR1.pressing()) {
     intake.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
   } else if (controller1.ButtonR2.pressing()) {
     // Spin the intake in the opposite direction when the R2 button is pressed
     intake.spin(vex::directionType::rev, 100, vex::velocityUnits::pct);
   } else {
     // Stop the intake when neither button is pressed
     intake.stop(vex::brakeType::coast);
   }
 }


 

  }
}
}
int main() {
  // create competition instance
  competition Competition;

  // Set up callbacks for autonomous and driver control periods.
  Competition.autonomous(autonomous);
  Competition.drivercontrol(userControl);

  // Run the pre-autonomous function.
  preAutonomous();

  // Prevent main from exiting with an infinite loop.
  while (true) {
    wait(100, msec);
  }
}}

I think your problems are occuring as a result of the 2 userControl(void). In addition you can’t have more than one while(true) loop in a single function as the whole true loop will not end and not allow the code to go down to read the other ones. I recommend combining them into one while(true) loop or using multithreading