Randomizer code not working.

Am trying to build a randomizer code for use in a random generator i’m building for a friend (hence the various works referenced in the variables). It’s meant to select from a preset array list based on the select variables whenever the random selection button is pressed, and i’ve got it to a point where it feels like the only two bits not working are the randomizer line itself and the output to an input field (which could easily fix itself if the first issue is solved). I’m not an efficient coder, so there’s some repeated things, but I was wondering if anyone can see what i’m doing wrong with this at a cursory glance?

I wasn’t sure what to cut out for ease of reading, so just know the actual randomizer code line itself is repeated for multiple different situations in the TaskOnClick function.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class RandGenName : MonoBehaviour {

	public Button nameButton;
	public Toggle togMLP; 
	public Toggle togRWBY;
	public Toggle tog40K;
	public int checkMLP;
	public int checkRWBY;
	public int check40K;
	public int checkTotal;
	string resultText;
	public Text resultOutput;

	/*40K = 1*/ public List<string> rand1 = new List<string>();
	/*MLP = 2*/ public List<string> rand2 = new List<string>();
	/*RWBY= 4*/ public List<string> rand4 = new List<string>();
	/*40K/MLP = 3*/ public List<string> rand3 = new List<string>();
	/*40K/RWBY= 5*/ public List<string> rand5 = new List<string>();
	/*MLP/RWBY= 6*/ public List<string> rand6 = new List<string>();
	/*All = 7*/ public List<string> rand7 = new List<string>();

	public void Start () {
		tog40K.isOn = false;
		togMLP.isOn = false;
		togRWBY.isOn = false;
		check40K = 0;
		checkMLP = 0;
		checkRWBY = 0;
		checkTotal = 0;
		resultText = "";
		nameButton.onClick.AddListener (TaskOnClick);
	}

	public void Update () {
		if (tog40K.isOn) {
			check40K = 1;
		}else{
			check40K = 0;
		}
		if (togMLP.isOn) {
			checkMLP = 2;
		}else{
			checkMLP = 0;
		}
		if (togRWBY.isOn) {
			checkRWBY = 4;
		}else{
			checkRWBY = 0;
		}
		checkTotal = check40K + checkMLP + checkRWBY;
		resultOutput.text = resultText;
		//Debug.Log (checkTotal);
	}
		
	public void TaskOnClick () {
		if (checkTotal == 1) {
			string resultText = rand1[Random.Range(0, rand1.Count)];
			resultOutput = GetComponent<Text>();
				resultOutput.text = resultText;
			Debug.Log (resultOutput);
		}
		if (checkTotal == 2) {
			string resultText = rand2[Random.Range(0, rand2.Count)];
			resultOutput = GetComponent<Text>();
				resultOutput.text = resultText;
			Debug.Log (resultOutput);
		}
		if (checkTotal == 3) {
		}
		if (checkTotal == 4) {
			string resultText = rand4[Random.Range(0, rand4.Count)];
			resultOutput = GetComponent<Text>();
				resultOutput.text = resultText;
			Debug.Log (resultOutput);
		}
		if (checkTotal == 5) {
		}
		if (checkTotal == 6) {
		}
		if (checkTotal == 7) {
		}
	}
}

What exactly doesn’t work with your code? string resultText = rand1[Random.Range(0, rand1.Count)]; is simple enough that it shouldn’t fail (though I think you could have problems here if your rand1 list was empty). Split that code and check the values of your random numbers:

int count = rand1.Count;
Debug.Log("rand1 count: " + count);
int randNumber = Random.Range(0, count);
Debug.Log("random number: " + randNumber);
string resultText = rand1[randNumber];