Object reference not set to an instance of an object error C#

Just an error that I don’t posses the skill to fix. The error is on line 63.

using UnityEngine;
using System.Collections;

public class floorbuilder : MonoBehaviour {

	//floors
	public GameObject[] fourrooms;
	public GameObject[] threerooms;
	public GameObject[] tworooms;
	public GameObject[] onerooms;
	public GameObject[] startrooms;
	GameObject[] currentfloor4;
	GameObject[] currentfloor3;
	GameObject[] currentfloor2;
	GameObject[] currentfloor1;
	//data containment
	public static int floornumb = 1;
	float doornumb;
	float roomnumb = 4; 
	float fourdoornumb;
	float threedoornumb;
	float twodoornumb;
	float onedoornumb;
	public int Size_Increase_Factor = 3;
	//positional variables
	int xnumb = 0;
	int znumb = 0;
	float snumb = 0;
	float rnumb = 0;

	void Start () {
		transform.position = new Vector3 (0, 0, 0);
		buildnextfloor ();
	}

	void buildnextfloor(){

		//Math determining the number of rooms and doors relitive to the floor level and shape of room positioning
		roomnumb = /*(insert mathy stuff stuff here)*/ (roomnumb + roomnumb) * Size_Increase_Factor;
		fourdoornumb = (Mathf.Round(roomnumb * (Random.Range(0.2f, 0.5f))));
		threedoornumb = (Mathf.Round(roomnumb * (Random.Range(0.1f, 0.4f))));
		twodoornumb = (Mathf.Round(roomnumb * (Random.Range(0.1f, 0.3f))));
		onedoornumb = (Mathf.Round(roomnumb * (Random.Range(0.1f, 0.3f))));
		doornumb = (fourdoornumb * 4) + (threedoornumb * 3) + (twodoornumb * 2) + (onedoornumb);
		roomnumb = (fourdoornumb) + (threedoornumb) + (twodoornumb) + (onedoornumb);

		if (doornumb % 2 == 1) {
			onedoornumb ++;

			doornumb = (fourdoornumb * 4) + (threedoornumb * 3) + (twodoornumb * 2) + (onedoornumb);
			roomnumb = (fourdoornumb) + (threedoornumb) + (twodoornumb) + (onedoornumb);
		}

		Debug.Log ("Number of rooms: " + roomnumb);
		Debug.Log ("Number of doors: " + doornumb);
		Debug.Log ("4doors: " + fourdoornumb); 
		Debug.Log ("3doors: " + threedoornumb);
		Debug.Log ("2doors: " + twodoornumb);
		Debug.Log ("1door: " + onedoornumb);

		//Selection of rooms
		for (int i = 0; i < fourdoornumb; i++) {
			currentfloor4 *= fourrooms[(Random.Range(0, fourrooms.Length))];* 
  •  }*
    
  •  for (int i = 0; i < threedoornumb; i++) {*
    

_ currentfloor3 = threerooms[(Random.Range(0, threerooms.Length))];_
* }*
* for (int i = 0; i < twodoornumb; i++) {*
_ currentfloor2 = tworooms[(Random.Range(0, tworooms.Length))];
* }
for (int i = 0; i < onedoornumb; i++) {
currentfloor1 = onerooms[(Random.Range(0, onerooms.Length))];
}*_

* snumb = (Mathf.Round((Mathf.Sqrt (roomnumb))));*
_ rnumb = roomnumb - (snumb * snumb);
snumb = snumb * 100;
rnumb = rnumb * 100;_

* //placing of rooms*

* Instantiate (startrooms[Random.Range(0, startrooms.Length)], transform.position, transform.rotation);*
* updatelocation ();*

* for(int i = 0; i < fourdoornumb; i ++){*
_ Instantiate(currentfloor4*, transform.position, transform.rotation);
updatelocation();
}
for(int i = 0; i < threedoornumb; i ++){
Instantiate(currentfloor3, transform.position, transform.rotation);
updatelocation();
}
for(int i = 0; i < twodoornumb; i ++){
Instantiate(currentfloor2, transform.position, transform.rotation);
updatelocation();
}
for(int i = 0; i < onedoornumb; i ++){
Instantiate(currentfloor1, transform.position, transform.rotation);
updatelocation();
}
}*_

* void updatelocation(){*
* if(xnumb < snumb){*
* xnumb += 100;*
* }*
* else if (znumb < snumb){*
* znumb += 100;*
* xnumb = 0;*
* }*
* else{*
* znumb += 100;*
* }*

* transform.position = new Vector3 (xnumb, 0f, znumb);*
* }*
}

Any help would be awesome.

After looking at your code again I can see the error lies in your fields. You have not yet initialized your GameObject arrays

 GameObject[] currentfloor4;

When must initiatlize your array, you must know how many elements you’re gonna use, example:

GameObject[] gameObjects = new GameObject[10] // array lenght of 10

You can also initialize the arrays in the Start() function and in that function determine the length you’re going to need on that array.

Now, while I have not thoroughly read through your code, my suggestion is that what you’re looking for is actually a dictionary. I’ve found this page to hold some nice information about just that Unity Coding: Arrays, Hashtables and Dictionaries explained | robotduck