variable declaration problems

I have a setup with a RFID-RC522 and a 1602 LCD with an uno r3
On top before setup I declared int score1 = scorePLR1 and int score2 = scorePLR2, then in my code i declared scorePLR1 like this:

if(str[0] == 117)                      
            {
                lcd.clear(); 
                randNumber117 = random(301);
                Serial.print("Hello Sjoerd!\n");
                lcd.setCursor(0,0);
                lcd.print("SJOERD SCORE");  
                lcd.setCursor(0,1);
                lcd.print(randNumber117);  
                delay(screen);                           
                int scorePLR1 = randNumber117;}

and scorePLR2 like this:

else if(str[0] == 68) 
            {      
                lcd.clear();  
                randNumber68 = random(301);
                Serial.print("Hello Noah!\n");
                lcd.setCursor(0,0);
                lcd.print("NOAH SCORE");  
                lcd.setCursor(0,1);
                lcd.print(randNumber68);  
                delay(screen);   
                int scorePLR2 = randNumber68;

On the bottom I did something like this:

if (score1 > score2)  {
      lcd.clear();
      lcd.setCursor(0,1);
      lcd.print("PLR 1 WINS");
    }
    
if (score2 > score1)  {
      lcd.clear();
      lcd.setCursor(0,1);
      lcd.print("PLR 2 WINS");
    }
    
if (score2 == score1)  {
      lcd.clear();
      lcd.setCursor(0,1);
      lcd.print("IT'S A TIE");
    }

Now the problem is that I get this error:

LCD_jelmar.ino: In function 'void setup()':
LCD_jelmar:24: error: 'scorePLR1' was not declared in this scope
LCD_jelmar:25: error: 'scorePLR2' was not declared in this scope
LCD_jelmar.ino: In function 'void loop()':
LCD_jelmar:242: error: 'score1' was not declared in this scope
LCD_jelmar:242: error: 'score2' was not declared in this scope
LCD_jelmar:248: error: 'score2' was not declared in this scope
LCD_jelmar:248: error: 'score1' was not declared in this scope
LCD_jelmar:254: error: 'score2' was not declared in this scope
LCD_jelmar:254: error: 'score1' was not declared in this scope
LCD_jelmar.ino: At global scope:
LCD_jelmar:261: error: expected declaration before '}' token
'scorePLR1' was not declared in this scope

I tried to move the declaration of score1 and score2 to setup and tried them in loop. None of that helped. With google i didn't come far, the only thing I find is that the declaration of a variable in loop will reset every 'new' loop. What can be done about it?

and for my entire code, srry didn't fit:

#include <LiquidCrystal.h>
#include <AddicoreRFID.h>
#include <SPI.h>
const int numRows = 2;
const int numCols = 16;
#define  uchar unsigned char
#define uint  unsigned int
long randNumber117;
long randNumber21;
long randNumber116;
long randNumber68;
int screen = 1000;
uchar fifobytes;
uchar fifoValue;
const int chipSelectPin = 3;
const int NRSTPD = 1;
LiquidCrystal lcd(6, 7, 5, 4, 3, 2);
#define MAX_LEN 16
AddicoreRFID myRFID;
int knop = 8;
int score1 = scorePLR1;
int score2 = scorePLR2;

void setup() {
  
  Serial.begin(9600);     
  SPI.begin();
  lcd.begin(numCols, numRows);
  lcd.clear();
    pinMode(chipSelectPin,OUTPUT);              
    digitalWrite(chipSelectPin, LOW);         
    pinMode(NRSTPD,OUTPUT);                     
    digitalWrite(NRSTPD, HIGH);
  myRFID.AddicoreRFID_Init();
    pinMode(2, INPUT);
  randomSeed(analogRead(0));
}

void loop() {
 
  lcd.setCursor(0,0);
  lcd.print(" SCAN PLAYER 1");
  lcd.setCursor(0,1);
  lcd.print(" Here ");
  delay(1000);
 
  uchar i, tmp, checksum1;
  uchar status;
        uchar str[MAX_LEN];
        uchar RC_size;
        uchar blockAddr;          //Selection operation block address 0 to 63???????
        String mynum = "";

        str[1] = 0x4400;
  //Find tags, return tag type
  status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str); 
   if (status == MI_OK)
  {
            Serial.println("RFID tag detected");
          Serial.print(str[0],BIN);
            Serial.print(" , ");
          Serial.print(str[1],BIN);
            Serial.println(" ");
  }
                              
                                //Anti-collision, return tag serial number 4 bytes???????
  status = myRFID.AddicoreRFID_Anticoll(str);
  if (status == MI_OK)
  {
            checksum1 = str[0] ^ str[1] ^ str[2] ^ str[3];
            Serial.println("The tag's number is  : ");
          //Serial.print(2);
          Serial.print(str[0]);
            Serial.print(" , ");
          Serial.print(str[1],BIN);
            Serial.print(" , ");
          Serial.print(str[2],BIN);
            Serial.print(" , ");
          Serial.print(str[3],BIN);
            Serial.print(" , ");
          Serial.print(str[4],BIN);
            Serial.print(" , ");
            Serial.println(checksum1,BIN);
            
          
            
            if(str[0] == 117)                      
            {
                lcd.clear(); 
                randNumber117 = random(301);
                Serial.print("Hello Sjoerd!\n");
                lcd.setCursor(0,0);
                lcd.print("SJOERD SCORE");  
                lcd.setCursor(0,1);
                lcd.print(randNumber117);  
                delay(screen);                           
                int scorePLR1 = randNumber117;
                
            } else if(str[0] == 21) {      
                lcd.clear();                                
                randNumber21 = random(301);
                Serial.print("Hello Mike!\n");
                lcd.setCursor(0,0);
                lcd.print("MIKE SCORE");  
                lcd.setCursor(0,1);
                lcd.print(randNumber21);  
                delay(screen);   
                int scorePLR1 = randNumber21;                        
                
            }
             else if(str[0] == 68) {      
                lcd.clear();  
                randNumber68 = random(301);
                Serial.print("Hello Noah!\n");
                lcd.setCursor(0,0);
                lcd.print("NOAH SCORE");  
                lcd.setCursor(0,1);
                lcd.print(randNumber68);  
                delay(screen);   
                int scorePLR1 = randNumber68;                       
             
            }
             else if(str[0] == 116) {  
                lcd.clear();           
                randNumber116 = random(301);
                Serial.print("Hello Jelmar!\n");
                lcd.setCursor(0,0);
                lcd.print("JELMAR SCORE");  
                lcd.setCursor(0,1);
                lcd.print(randNumber116); 
                delay(screen); 
                int scorePLR1 = randNumber116;                          
               
            }
            Serial.println();
           
  }
    
        myRFID.AddicoreRFID_Halt();     
        delay(1000);







          lcd.setCursor(0,0);
  lcd.print(" SCAN PLAYER 2");
  lcd.setCursor(0,1);
  lcd.print(" Here ");
  delay(1000);
 
          str[1] = 0x4400;
  //Find tags, return tag type
  status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str); 
   if (status == MI_OK)
  {
            Serial.println("RFID tag detected");
          Serial.print(str[0],BIN);
            Serial.print(" , ");
          Serial.print(str[1],BIN);
            Serial.println(" ");
  }
                              
                                //Anti-collision, return tag serial number 4 bytes???????
  status = myRFID.AddicoreRFID_Anticoll(str);
  if (status == MI_OK)
  {
            checksum1 = str[0] ^ str[1] ^ str[2] ^ str[3];
            Serial.println("The tag's number is  : ");
          //Serial.print(2);
          Serial.print(str[0]);
            Serial.print(" , ");
          Serial.print(str[1],BIN);
            Serial.print(" , ");
          Serial.print(str[2],BIN);
            Serial.print(" , ");
          Serial.print(str[3],BIN);
            Serial.print(" , ");
          Serial.print(str[4],BIN);
            Serial.print(" , ");
            Serial.println(checksum1,BIN);
            
          
            
            if(str[0] == 117)                      
            {
                lcd.clear(); 
                randNumber117 = random(301);
                Serial.print("Hello Sjoerd!\n");
                lcd.setCursor(0,0);
                lcd.print("SJOERD SCORE");  
                lcd.setCursor(0,1);
                lcd.print(randNumber117);  
                delay(screen);                           
                int scorePLR2 = randNumber117;
                
            } else if(str[0] == 21) {      
                lcd.clear();                                
                randNumber21 = random(301);
                Serial.print("Hello Mike!\n");
                lcd.setCursor(0,0);
                lcd.print("MIKE SCORE");  
                lcd.setCursor(0,1);
                lcd.print(randNumber21);  
                delay(screen);   
                int scorePLR2 = randNumber21;                        
                
            }
             else if(str[0] == 68) {      
                lcd.clear();  
                randNumber68 = random(301);
                Serial.print("Hello Noah!\n");
                lcd.setCursor(0,0);
                lcd.print("NOAH SCORE");  
                lcd.setCursor(0,1);
                lcd.print(randNumber68);  
                delay(screen);   
                int scorePLR2 = randNumber68;                       
             
            }
             else if(str[0] == 116) {  
                lcd.clear();           
                randNumber116 = random(301);
                Serial.print("Hello Jelmar!\n");
                lcd.setCursor(0,0);
                lcd.print("JELMAR SCORE");  
                lcd.setCursor(0,1);
                lcd.print(randNumber116); 
                delay(screen); 
                int scorePLR2 = randNumber116;                          
               
            }
            Serial.println();
           
  } 
    
        myRFID.AddicoreRFID_Halt();     
        delay(1000);

    if (score1 > score2)  {
      lcd.clear();
      lcd.setCursor(0,1);
      lcd.print("PLR 1 WINS");
    }
    
    if (score2 > score1)  {
      lcd.clear();
      lcd.setCursor(0,1);
      lcd.print("PLR 2 WINS");
    }
    
     if (score2 == score1)  {
      lcd.clear();
      lcd.setCursor(0,1);
      lcd.print("IT'S A TIE");
    }
    delay(10000);
    } 
}

You have an extra "}" at the end of your program.

thanks, how stupid of me, but still the error of no declaration.

You will have to declare these
scorePLR1
scorePLR2

int score1 = scorePLR1; ??
int score2 = scorePLR2; ??

The compiler often generates errors based on errors. So always look at the first one!

Thanks, I fixed it. Did paste the declaration on the bottom in void loop

Jello0100:
Thanks, I fixed it. Did paste the declaration on the bottom in void loop

That's a very odd place to put it. But hey, if it works...