hopper Problem Detection

Hello Every One,

I am Using an arduino Uno and I would like to ask for a help I am trying to make a coin counter to be activated by RFID and the problem is my hopper is not counting correctly, its always exceeding one, I've tried to research about this but i cant find exact solution or the same problem as i am. below is the code I've made please be kind I'm just a beginner.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;
const int i2c_addr = 0x27;
LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);

int ID LED = A2;
int motorSilver = A0; //Silver token Hopper
int motorGold = A1; //Gold Token Hopper
int motorTrigger = 5; //motor trigger
int error = 2;

int silverSensorPin = 7;
int silverSensorCount = 0;
int silverSensorState = 0;
int lastSilverSensorState = 1;
int goldSensorPin = 6;
int goldSensorCount = 0;
int goldSensorState = 0;
int lastGoldSensorState = 1;

unsigned long previousMillis = 0;

void setup() //Initializing
{
lcd.begin(16, 2);
lcd.setCursor(0, 0); //Print on first row
lcd.print(" ");

Serial.begin(9600); //Initiate a serial communication
SPI.begin(); //Initiate SPI bus
mfrc522.PCD_Init();

pinMode (silverSensorPin, INPUT);
pinMode (goldSensorPin, INPUT);
pinMode (motorTrigger, INPUT);
pinMode (add3, OUTPUT);
pinMode (add20, OUTPUT);
pinMode (add25, OUTPUT);
pinMode (error, OUTPUT);
pinMode (motorSilver, OUTPUT);
pinMode (motorGold, OUTPUT);
digitalWrite (motorSilver, HIGH);
}

void loop()
{
RFID();
if (digitalRead(ID_LED) == HIGH)
{
if (digitalRead(motorTrigger) == HIGH)
{
digitalWrite(motorSilver, LOW);
}

if ((digitalRead(motorSilver) == LOW))
{
long time = 5000;
unsigned long currentMillis = millis();
if ((silverSensorState ==HIGH) && (currentMillis - previousMillis >= time))
{
digitalWrite (error, HIGH);
digitalWrite (motorSilver , HIGH);
}
}
sample();
if (silverSensorCount == 10)
{
digitalWrite(motorSilver, HIGH);
}
if (digitalRead(motorGold) == HIGH && goldSensorCount == 3)
{
digitalWrite(ID_LED, LOW);
delay(2000);
silverSensorCount = 0;
goldSensorCount = 0;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Thank You!");
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("");
}
}
}

void Counter()
{
silverSensorState = digitalRead(silverSensorPin);
goldSensorState = digitalRead(goldSensorPin);
if ((silverSensorState != lastSilverSensorState) || (goldSensorState != lastGoldSensorState))
{
if (silverSensorState == LOW)
{
silverSensorCount++;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Silver Token =");
lcd.print(silverSensorCount);
}
lastSilverSensorState = silverSensorState;

if (goldSensorState == LOW)
{
goldSensorCount++;
lcd.setCursor(0, 1);
lcd.print("Gold Token =");
lcd.print(goldSensorCount);
}
lastGoldSensorState = goldSensorState;
}
}

void sample()
{
Counter();
if (silverSensorCount == 10)
{
digitalWrite(motorSilver, HIGH);
digitalWrite(motorGold, LOW);
}
if (goldSensorCount == 3)
{
digitalWrite(motorGold, HIGH);
}
}

void RFID()
{
if ( ! mfrc522.PICC_IsNewCardPresent()) // Look for new cards
{
return;
}
if ( ! mfrc522.PICC_ReadCardSerial()) // Select one of the cards
{
return;
}
Serial.print("UID tag :"); //Show UID on serial monitor
String content = "";
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte < 0x10 ? " 0" : " ");
_ Serial.print(mfrc522.uid.uidByte*, HEX);_
_ content.concat(String(mfrc522.uid.uidByte < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte, HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "D4 56 E4 59") //change here the UID of the card/cards that you want to give access*

* {
digitalWrite(add3, HIGH);
digitalWrite(add20, LOW);
digitalWrite(add25, LOW);
}
}[/color]*

*there is two hopper for the counter, the process of this counter is when i tap the RFID the Id_LED will light upand button(motorsilver) will be activated and when pressed, the motor of hopper for silver token will activate and start counting and will stop when it reach to 10 and when it reach 10 another hopper will activate and count up to 3 gold token. but this 2 hopper always exceed in one so th count is 11 and 4 *
the code highlighted in orange is the code when to stop the hopper
and I add the code higlighted in red to detect if the hopper clogged but its not working the millis is starting to count when i power on the arduino. please kindly help me with this._

First, please post within </> code-tags, and i think you should separate the first if statement here:

  if ((silverSensorState != lastSilverSensorState) || (goldSensorState != lastGoldSensorState))
  {
    if (silverSensorState == LOW)
    {
      silverSensorCount++;
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Silver Token =");
      lcd.print(silverSensorCount);
    }
    lastSilverSensorState = silverSensorState;
    
    if (goldSensorState == LOW)
    {

so it will be

  if (silverSensorState != lastSilverSensorState) {
    if (silverSensorState == LOW)
    {
      silverSensorCount++;
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Silver Token =");
      lcd.print(silverSensorCount);
    }
    lastSilverSensorState = silverSensorState;
  }
if  (goldSensorState != lastGoldSensorState) {  
  if (goldSensorState == LOW)
    {

because now if the silverSensor has changed and the gold is low it will add to the gold, this is incorrect debouncing.