Invert motor directions within the code?

Hi!
I am coding the robot in my schools robotics elective. Our robot has 2 arms in the front and in the back for picking up mobile goals and my group wants to make it so the robot can switch directions of the motor so the driver can pick up the goal easier. We want to simultaneously change the direction of all 4 drive train motors, however I am not using a drive train. the motors are each independent. Is there a simple way to use a button to switch the direction of all motors simultaneously so reverse becomes forward and forward becomes reverse. This is my first post so I am sorry if I am missing anything.
Thanks!

You could use a variable that flips it for example (in pseudocode):

direction = -1 or 1 depending on the direction

motor 1 spins (90 * direction) degrees
motor 2 spins (90 * direction) degrees
motor 3 spins (90 * direction) degrees
motor 4 spins (90 * direction) degrees

Something like this could work (unless it doesn’t lol). The idea would be to reverse the inputs to the motors when the reversed variable is engaged. This is mostly pseudo code so it’s up to you to figure out declarations and setup based on whichever coding environment you’re using.

//Driver Control
while(true){

//Check for toggle
if(button is pressed){
 if(Reversed == true){
 Reversed = false;
} else {
Reversed = true;
 }
}

//Grab input from controller
Left = LeftControllerYAxis
Right = RightControllerYAxis

//Reverse Motors if enabled
if(Reversed){
Left = Left * -1;
Right = Right * -1;
}

//Set Motors
FR = Right;
BR = Right;
FL = Left;
BL = Left;

delay(10); //millis

}