Help changing text with a button and a for loop

I need help with making a story system for my game. Now I have a very clear image in my head about what exactly I want to do. The scene will be run in between level scenes. I want the system to have text, and a button, this button will advance the text forward, and these messages you can change via a public string array. The story system will be similar to that of The Battle For Westnoth if that helps

Here is my code so far
using UnityEngine;
using UnityEngine.UI;

public class StoryMessage : MonoBehaviour {

    public string[] messages;

    private Text text;
    private int messageCounter = 1;

    void Awake() {
        text = GetComponent<Text>();
    }

    void Update () {
		
    }

    public void UpdateMessage() {
        messageCounter ++;
    }
}

Create a UI Text and a UI Button in the Editor. Create a public Text and a public Button variable in the script, and assign these UI elements to them. Or find them by:

textVariable = GameObject.Find("TextGameObject").GetComponent<Text>();
buttonVariable = GameObject.Find("ButtonGameObject").GetComponent<Button>();

Now, you must assign a method to the onClick event of the Button. You can do this by:

buttonVariable.onClick.AddListener(() => UpdateMessage());

After this, you only have to change the text according to the ‘messageCounter’ variable in the UpdateMessage() function.

textVariable.text = messages[messageCounter];

I assume that you have already filled the ‘messages’ array with the strings. Be sure to check the messageCounter variable if it can be increased, otherwise it will return an IndexOutOfRange exception.

public void UpdateMessage() {
	if(messageCounter == messages.Length - 1) return;
	messageCounter ++;
    textVariable.text = messages[messageCounter];
}