Dialogue problems?

The problem is that the text is not allowing me to exit after it has exceeded the index for some reason, and is adding the text at its original index. I’m very confused and have done all I can to try and fix it. Any help is very appreciated.

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

public class DialogueManager : MonoBehaviour {
	public Text textdisplay;
	public Text nametext;
	public string[] sentences;
    public string[] names;
	private int index;
    private int end = 2;
    public float typingspeed;
	public GameObject uimanager;
	public static bool displayText = false;
    private bool isActive = false;


	private string trig;

	public GameObject continueButton;
	public GameObject script;

	void Start () {
	}

	private void Update()
    {
        trig = Clicker.trigname;
        NameTxt();
        Conversations();
		if (displayText == true)
		{
			uimanager.SetActive(true);
		}
		else
		{
			uimanager.SetActive(false);
		}
		if (textdisplay.text == sentences[index])
		{
			continueButton.SetActive(true);
		}
	}

	IEnumerator Type()
	{
		foreach (char letter in sentences[index].ToCharArray())
		{
            if(index <= end)
            {
                textdisplay.text += letter;
                yield return new WaitForSeconds(typingspeed);
            }
            else
            {
                isActive = false;
                displayText = false;
            }
		}
	}

    public void NextSentence()
    {
        continueButton.SetActive(false);

        if (index < sentences.Length - 1 && index < end) {
			index++;
			textdisplay.text = "";
			StartCoroutine(Type());
		}
        else
		{
            isActive = false;
			displayText = false;
		}
	}

	void NameTxt()
	{
        nametext.text = names[index];
	}


    //Problem: GOES BACK TO THE FIRST SENTENCE? THEN STOPS ALLOWING YOU TO EXIT.
    void Conversations()
    {
        Conv1();
        Conv2();
    }

	void Conv1()
	{
        
		if(trig == "conv1" && isActive == false)
		{
            index = 0;
            end = 2;
            isActive = true;
            displayText = true;
            StartCoroutine(Type());
		}
	}

    void Conv2()
    {
        if (trig == "conv2" && isActive == false)
        {
            index = 3;
            end = 5;
            isActive = true;
            displayText = true;
            StartCoroutine(Type());
        }
    }
}

Umm, there is probably a bug. Do you have any exceptions? Since it’s called inside the Update, it’s possible it fails somewhere, then exits, and goes back Update then to first sentence. Have you checked that possibility?

Edit : @3kWikiGames i think i found the problem :

  • You are comparing strings to enable the button. However, from your screen shot, the strings are additive.
  • in the first turn, your dialogue text = first text, but in the second turn, dialogue = text1 + text2 instead of text2.
  • Either check for additive resulting string, or change the way your make your check to something else.