Random.Range method "left-hand side" error

Hi all, very new to programming and so forgive this noob question and my possibly embarrassing code posted below. I’m trying to create a method for assigning randomly generated value, but keep getting “error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer”

  public int heroView () {
    		if (party == "Outlaw" && party == "Mercenary") {
    			heroView = Random.Range (1, 25);
    		} 
    		else {
    			heroView = Random.Range (0, 100);
    		}
    	}

`

your function name “heroView” and the variable in which you are saving the value returned from Random.Range also named “heroView”. Just change one of them. :slight_smile:

Your using Random.Range correctly. The issue is you are not assigning it to a proper variable. You have a method called ‘heroView’ that is looking for a return type of int, but you are not returning anything.

Simple fix:

	public int HeroView () {
		 if (party == "Outlaw" && party == "Mercenary") {
			 return Random.Range (1, 25);
		 } 
		 else {
			 return Random.Range (0, 100);
		 }
	}