Creating a dialogue?

OK, here is the problem, i want to create a dialogue scene, where the player walks to an NPC, presses “E” and the NPC will speak at the bottom of the screen, much like subtitles.

function playSpeech1() : IEnumerator  {
 for (var letter in word.ToCharArray()) {
  wordUI.text += letter;
  yield WaitForSeconds(letterPause);
function removeText() {
 yield WaitForSeconds(4);
 wordUI.text = "";

This is my current script which at the moment autotypes a String, when finished, removes the text.

Now the question is, how would i make a multi-string dialogue?

for example:

  1. “Hello there”
  2. //remove text
  3. “How can i help you?”
  4. //remove text

I’m not sure this is the most effective way, but is there an easier solutions, possibly considering an Array

“word” should be an array and your current body of playSpeech1 should be enclosed within a “for” that loops through the array elements