How can I make Random.Range() take variables?

I want to do something like this, but it isn’t working. Couldn’t find anything on Google. Help?

float minHitDamage;
float maxHitDamage;
float damageOnStrike;
int level = 1;

if (level = 1){
     float minHitDamage = 0;
     float maxHitDamage = 10;
}

if (level = 2){
     float minHitDamage = 10;
     float maxHitDamage = 30;
}


damageOnStrike = Random.Range(minHitDamage, maxHitDamage);

Since you’ve already defined the variables as float at the top, don’t redefine them here:

 if (level = 1){
      float minHitDamage = 0;
      float maxHitDamage = 10;
 }
 
 if (level = 2){
      float minHitDamage = 10;
      float maxHitDamage = 30;
 }

Instead, that should be:

 if (level == 1){
      minHitDamage = 0;
      maxHitDamage = 10;
 }
 
 if (level == 2){
      minHitDamage = 10;
      maxHitDamage = 30;
 }

Note the variable types are not defined again and the equality checks have been fixed (not “=”, but "==).