Arduino to Arduino XBee communication not working

I’m currently working on a project that requires two XBees to communicate. One Arduino, with an XBee shield and XBee sends a command and readings of 4 flex sensors to another Arduino and XBee, which takes the command and powers two DC motors. When I use a dongle connected to my laptop and send values to the XBee from the first XBee (Arduino to Dongle), it receives the correct values. However, when I move the XBee back to the Arduino (Arduino to Arduino), the XBee does not receive any values, and when I print XBee.read() it prints “-1”.
Here’s a snippet of the code from the Arduino receiving values

//#include <Servo.h>
#include <SoftwareSerial.h> 
SoftwareSerial XBee(2,3);
int enA = 12;
int in1 = 11;
int in2 = 8;
// motor two
int enB = 5;
int in3 = 7;
int in4 = 6;
int claw_ang=0;
int tilt_ang=15;
//Servo claw;
//Servo tilt;

void setup()
{
  //claw.attach(3);
  //tilt.attach(4);
  Serial.begin(9600);
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}

void loop()
{
  if (XBee.available()>=5) { //should be receiving either an 'e' or an 's' as well as four numerical values 
  
   char incomingByte1 = XBee.read();
   char incomingByte2 = XBee.read(); 
   char incomingByte3 = XBee.read();
   char incomingByte4 = XBee.read();
   char incomingByte5 = XBee.read();
   
   if(incomingByte1=='e'){  // if the first byte is an 'e' it should be controlling the motors
    
   int val_1 = incomingByte2-'0';
   int val_2 = incomingByte3-'0';
   int val_3 = incomingByte4-'0';
   int val_4 = incomingByte5-'0';

Hello there!

I have had this error too, and I believe I remember hearing that XBee modules do not work unless connected to a computer. I will look more into this so don't take my word for it.

Can you tell me the specific model number or board revision or something specific so I can look up some tutorials for you?