Serial data only displayed if HC12 master has a 2 second delay

Hello, i am currently trying to make an Arduino rc car using 4x TT motors, an l298n motor controller, an Arduino mega, uno and a pair of hc12 transceivers. Both HC12 are or the same settings (default).

However i have an issue, the basic code to test a HC12 works, i can send "hello world" from the master to the slave however when i try to send data to the Arduino mega (slave) it will only receive data if the Arduino unos code has a 2 second delay in the loop.
Even with this, the data received by the master is inconsistent and sometimes takes up to 8 seconds to update. Does anyone know where i am going wrong here? Thanks in advance.

The Slave code is as follows:

//MOTOR 1
int motor1pin1 = 2;
int motor1pin2 = 3;


//MOTOR 2
int motor2pin1 = 4;
int motor2pin2 = 5;



void setup() {
  Serial.begin(9600); //GOTTA DO THIS CUZ REASONS...


  
  //DECLARING SPECIFIC MOTOR PINS AS OUTPUTS
  pinMode(motor1pin1, OUTPUT); 
  pinMode(motor1pin2, OUTPUT);
  pinMode(motor2pin1, OUTPUT);
  pinMode(motor2pin2, OUTPUT);



}

void loop() {



  

//DIRECTIONAL COMMANDS TO MOTORS
//FORWARD MOVEMENT
if(Serial.available() > 0)
    {
        String input = Serial.readString();
        if(input == "forward")
        {
  
  digitalWrite(motor1pin1, HIGH);
  digitalWrite(motor1pin2, LOW);

  digitalWrite(motor2pin1, HIGH);
  digitalWrite(motor2pin2, LOW);
  
        }
    }

  //BACKWARD MOVEMENT
if(Serial.available() > 0)
    {
        String input = Serial.readString();
        if(input == "backward")
        {
  digitalWrite(motor1pin1, LOW);
  digitalWrite(motor1pin2, HIGH);

  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, HIGH);
  
        }
    }

  //LEFT TURN
if(Serial.available() > 0)
    {
        String input = Serial.readString();
        if(input == "left")
        {
  digitalWrite(motor1pin1, HIGH);
  digitalWrite(motor1pin2, LOW);

  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, HIGH);
  
        }
    }

  //RIGHT TURN
if(Serial.available() > 0)
    {
        String input = Serial.readString();
        if(input == "right")
        {
  digitalWrite(motor1pin1, LOW);
  digitalWrite(motor1pin2, HIGH);

  digitalWrite(motor2pin1, HIGH);
  digitalWrite(motor2pin2, LOW);
  
        }
    }

  //IDLE (IF ALL BUTTONS ARE PRESSED)
if(Serial.available() > 0)
    {
        String input = Serial.readString();
        if(input == "idle")
        {
  
  digitalWrite(motor1pin1, LOW);
  digitalWrite(motor1pin2, LOW);

  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, LOW);
  
        }
    }
}

The Master Code:
``
int forwardbutton = 2;
int backwardbutton = 3;
int leftbutton = 4;
int rightbutton = 5;

void setup() {

  Serial.begin(9600);


  pinMode(forwardbutton, INPUT);
  pinMode(backwardbutton, INPUT);
  pinMode(leftbutton, INPUT);
  pinMode(rightbutton, INPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  

}

void loop() {


  pinMode(2, INPUT_PULLUP); //Sets pin 2 to a default HIGH
  pinMode(3, INPUT_PULLUP); //Sets pin 3 to a default HIGH
  pinMode(4, INPUT_PULLUP); //Sets pin  to a default HIGH
  pinMode(5, INPUT_PULLUP); //Sets pin 7 to a default HIGH

  forwardbutton = digitalRead(2);
  backwardbutton = digitalRead(3);
  leftbutton = digitalRead(4);
  rightbutton = digitalRead(5);

 
  if((forwardbutton == LOW)&&(backwardbutton == HIGH)&&(leftbutton == HIGH)&&(rightbutton == HIGH)){    

  
   Serial.println("forward");
   delay(2000);
  
  }
   if((forwardbutton == HIGH)&&(backwardbutton == LOW)&&(leftbutton == HIGH)&&(rightbutton == HIGH)){    

 
 Serial.println("backward");
 delay(2000);
  
  }
    if((forwardbutton == HIGH)&&(backwardbutton == HIGH)&&(leftbutton == LOW)&&(rightbutton == HIGH)){    

 
 Serial.println("left");
 delay(2000);

  }
    if((forwardbutton == HIGH)&&(backwardbutton == HIGH)&&(leftbutton == HIGH)&&(rightbutton == LOW)){    

 
 Serial.println("right");
 delay(2000);
  
  }
      if((forwardbutton == HIGH)&&(backwardbutton == HIGH)&&(leftbutton == HIGH)&&(rightbutton == HIGH)){    

 
 Serial.println("idle");
 delay(2000);
  
  }

    if((forwardbutton == LOW)&&(backwardbutton == LOW)&&(leftbutton == LOW)&&(rightbutton == LOW)){    

 
 Serial.println("idle");
 delay(2000);
  
  }


}

One thing that is wrong in the slave code

if(Serial.available() > 0)
    {
        String input = Serial.readString();
        if(input == "forward")
        {
...
...
if(Serial.available() > 0)
    {
        String input = Serial.readString();
        if(input == "backward")
        {
...
...
etcetera

What happens is that you check if data is available and next read it. If it's not "backward", you check again if data is available; that will hardly ever be the case so you will never get to the "forward".

You should check if data is available once and read once

if(Serial.available() > 0)
{
  String input = Serial.readString();

  if (input == "backward")
  {
  }
  else if (input == "forward")
  {
  }
  else if (input == "left")
  {
  }
  else if (input == "right")
  {
  }
  else  if (input == "idle")
  {
  }
  else
  {
    // invalid command
  }

Further be aware that readString has a default timeout of 2 seconds.

You might want to read Serial Input Basics - updated to get ideas how to properly handle serial input.

Please pay attention to the indentations of your code; it will make it easier to read. You did attempt to post two codes separated but it unfortunately failed; below the codes
slave

//MOTOR 1
int motor1pin1 = 2;
int motor1pin2 = 3;


//MOTOR 2
int motor2pin1 = 4;
int motor2pin2 = 5;



void setup() {
  Serial.begin(9600);  //GOTTA DO THIS CUZ REASONS...



  //DECLARING SPECIFIC MOTOR PINS AS OUTPUTS
  pinMode(motor1pin1, OUTPUT);
  pinMode(motor1pin2, OUTPUT);
  pinMode(motor2pin1, OUTPUT);
  pinMode(motor2pin2, OUTPUT);
}

void loop() {


  //DIRECTIONAL COMMANDS TO MOTORS
  //FORWARD MOVEMENT
  if (Serial.available() > 0) {
    String input = Serial.readString();
    if (input == "forward") {

      digitalWrite(motor1pin1, HIGH);
      digitalWrite(motor1pin2, LOW);

      digitalWrite(motor2pin1, HIGH);
      digitalWrite(motor2pin2, LOW);
    }
  }

  //BACKWARD MOVEMENT
  if (Serial.available() > 0) {
    String input = Serial.readString();
    if (input == "backward") {
      digitalWrite(motor1pin1, LOW);
      digitalWrite(motor1pin2, HIGH);

      digitalWrite(motor2pin1, LOW);
      digitalWrite(motor2pin2, HIGH);
    }
  }

  //LEFT TURN
  if (Serial.available() > 0) {
    String input = Serial.readString();
    if (input == "left") {
      digitalWrite(motor1pin1, HIGH);
      digitalWrite(motor1pin2, LOW);

      digitalWrite(motor2pin1, LOW);
      digitalWrite(motor2pin2, HIGH);
    }
  }

  //RIGHT TURN
  if (Serial.available() > 0) {
    String input = Serial.readString();
    if (input == "right") {
      digitalWrite(motor1pin1, LOW);
      digitalWrite(motor1pin2, HIGH);

      digitalWrite(motor2pin1, HIGH);
      digitalWrite(motor2pin2, LOW);
    }
  }

  //IDLE (IF ALL BUTTONS ARE PRESSED)
  if (Serial.available() > 0) {
    String input = Serial.readString();
    if (input == "idle") {

      digitalWrite(motor1pin1, LOW);
      digitalWrite(motor1pin2, LOW);

      digitalWrite(motor2pin1, LOW);
      digitalWrite(motor2pin2, LOW);
    }
  }
}

master

int forwardbutton = 2;
int backwardbutton = 3;
int leftbutton = 4;
int rightbutton = 5;

void setup() {

  Serial.begin(9600);


  pinMode(forwardbutton, INPUT);
  pinMode(backwardbutton, INPUT);
  pinMode(leftbutton, INPUT);
  pinMode(rightbutton, INPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
}

void loop() {


  pinMode(2, INPUT_PULLUP);  //Sets pin 2 to a default HIGH
  pinMode(3, INPUT_PULLUP);  //Sets pin 3 to a default HIGH
  pinMode(4, INPUT_PULLUP);  //Sets pin  to a default HIGH
  pinMode(5, INPUT_PULLUP);  //Sets pin 7 to a default HIGH

  forwardbutton = digitalRead(2);
  backwardbutton = digitalRead(3);
  leftbutton = digitalRead(4);
  rightbutton = digitalRead(5);


  if ((forwardbutton == LOW) && (backwardbutton == HIGH) && (leftbutton == HIGH) && (rightbutton == HIGH)) {


    Serial.println("forward");
    delay(2000);
  }
  if ((forwardbutton == HIGH) && (backwardbutton == LOW) && (leftbutton == HIGH) && (rightbutton == HIGH)) {


    Serial.println("backward");
    delay(2000);
  }
  if ((forwardbutton == HIGH) && (backwardbutton == HIGH) && (leftbutton == LOW) && (rightbutton == HIGH)) {


    Serial.println("left");
    delay(2000);
  }
  if ((forwardbutton == HIGH) && (backwardbutton == HIGH) && (leftbutton == HIGH) && (rightbutton == LOW)) {


    Serial.println("right");
    delay(2000);
  }
  if ((forwardbutton == HIGH) && (backwardbutton == HIGH) && (leftbutton == HIGH) && (rightbutton == HIGH)) {


    Serial.println("idle");
    delay(2000);
  }

  if ((forwardbutton == LOW) && (backwardbutton == LOW) && (leftbutton == LOW) && (rightbutton == LOW)) {


    Serial.println("idle");
    delay(2000);
  }
}

Further in the master, please consistently use the pin names. It does not make sense to sometimes use the pin name and sometimes use the pin number.

Lastly, why would you do the below in loop()? Also, the comment below is wrong.

pinMode(2, INPUT_PULLUP);  //Sets pin 2 to a default HIGH

Thanks a million for the help, really appreciate it. What you said solved my issue, it updates alot faster and more reliably now.