Store and resend Ir values

Hello, so I am trying to make a laser tag gun and I need some help with storing and sending ir codes.

So my code pretty much has two inputs and a couple outputs so here’s the gist of how it works. on startup, it’s going to check if the trigger is pulled and if the trigger is pulled while the Arduino is starting up it’s going to activate an IR sensor and look for a new IR code to overwrite the existing one. (So like at the beginning of a game if you want to change to a different vest) then it goes ahead and stores that information and the whole loop of the code is just checking whether the trigger is pulled and if the trigger is pulled then it’s going to check if the rapid-fire switch is flipped and if the rapid-fire switch is flipped it’s going to fire at a much higher rate than the single fire will.

The problem arises when I try to go ahead and store that code I don’t know how to decode the IR code and then store it in the variable called raw with all of the proper formatting such as commas.

I know my code is a little messy so if you want to improve anything on that as well feel free.

Thanks for your time

#include <IRremote.h>
int x;
int y;
int trigger;
int rapid;
int contact;

int triggerpin = 4;
int rapidpin = 5;
int irinpin = 6;
int laserpin = 7;
int irinonpin = 8;
int iroutpin = 3;

unsigned int raw[103] = {668, 7126,  2592, 670,  600, 1344,  624, 2024,  646, 1320,  598, 1992,  1922, 1376,  1916, 696,  3866, 1376,  646, 672,  600, 696,  598, 2640,  600, 754,  646, 7288,  2592, 672,  626, 1316,  598, 2050,  622, 1344,  598, 1992,  1920, 1376,  1918, 
696,  3866, 1374,  622, 696,  598, 696,  622, 2616,  624, 730,  620, 7234,  2590, 672,  598, 1346,  596, 2052,  648, 1318,  598, 1994,  1894, 1402,  1944, 670,  3864, 1296,  620, 698,  596, 700,  622, 2618,  622, 892,  620, 7232,  2566, 696,  624, 1320,  598, 2052,  
618, 1346,  622, 1970,  1920, 1376,  1942, 674,  3860, 1380,  646, 672,  596, 700,  596, 2642,  596};

// thats the default ir code ^

IRsend irsend;
IRrecv irrecv(irinpin);
decode_results results;


void setup()
{

  pinMode(triggerpin,INPUT);
  pinMode(rapidpin,INPUT);
  pinMode(irinpin,INPUT);
  pinMode(laserpin,OUTPUT);
  pinMode(iroutpin,OUTPUT);
  pinMode(irinonpin,OUTPUT);
  
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver

contact=digitalRead(triggerpin); // = Tell when the trigger is pulled during startup to see if you want to insert a difrent ir code
if (contact == HIGH) {
  digitalWrite(irinonpin, HIGH); // turns the ir input on
  delay(500);
   Serial.println("waiting for input"); // debug stuff
  while(y == 0){
   if (irrecv.decode(&results)) // receves the ir code from the ir recever and decodes it
    {

      
     x = results.value; // Stores the IR code <------------------------------------------------------------------
    // I want to overwrite the main "raw" variable and replace it with a new IR code but I don't know how it set up the code to take the results and save it with the correct format.
     
     Serial.println("input recived"); // debug stuff
      delay(10);
      y = 1;
    }
    
  }
  digitalWrite(irinonpin, LOW); // turns off the recever
  Serial.println("got input"); // debug stuff
    Serial.println("moving on..."); // debug stuff
}

}  
void loop() 

{   
trigger=digitalRead(triggerpin);
rapid=digitalRead(rapidpin);

if (trigger == HIGH) { //did the trigger get pulled?
  if(rapid == HIGH){ // is rapid fire switch on?
    while(trigger == HIGH){ // rapid fire loop
      
      digitalWrite(laserpin,HIGH);
      delay(100);
      digitalWrite(laserpin,LOW);
      delay(50);
      irsend.sendRaw(raw,103,38);
     trigger=digitalRead(triggerpin); // checks to see when the trigger is releced so we can stop rapid fire
    }
    
  }
  irsend.sendRaw(raw,103,38);  // sends the ir code
   digitalWrite(laserpin,HIGH); // lazer fire
      delay(100);
      digitalWrite(laserpin,LOW);
  delay(300); // to give time so you can let off the trigger and not double fire
  
}
}