Changing Text after Button Click

Hi, as you can see the thread header I just want change specific text when I click the button. I wrote script but still dont get why does not work.

Script Name:StartScreenTextChanger

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class StartScreenTextChanger : MonoBehaviour
{
public Text changingText;
private Text OpeningText1, OpeningText2, OpeningText3;
int textIndex = 0;
public void TextChange()
{
OpeningText1.text = "text one";
OpeningText2.text = "text two";
OpeningText3.text = "text three";
switch (textIndex)
{ 
case 0:
changingText.text = OpeningText1.text;
textIndex++;
break;
case 1:
changingText.text = OpeningText2.text;
textIndex++;
break;
case 2:
changingText.text = OpeningText3.text;
textIndex++;
break;
default:
gameObject.SetActive(false);
break;
} 
}
}

When I click run, I get this error message :

NullReferenceException: Object reference not set to an instance of an object
StartScreenTextChanger.TextChange () (at Assets/StartScreenTextChanger.cs:25)

Thanks for reading

You should make sure your variables are set. changingText probably needs to be set on your MonoBehaviour in the scene. And same goes for the three OpeningTextX. Or if these are supposed to be static text, I would suggest to convert to simple string variables and initialize them outside the method.

private string OpeningText1 = “text one”;
private string OpeningText2 = “text two”;
private string OpeningText3 = “text three”;