How do I make a Dialog system?

Good afternoon guys, so I wanted to make a dialogue system in my game I saw a video of a guy doing it, but he only taught how the NPC speaks, not how more than one NPC speaks.

Here is the code for the Dialog Box:

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

public class CaixaDialogo : MonoBehaviour
{
    public Sprite profile;
    public string[] speechText;
    public string actorName;

    public LayerMask playerLayer;
    public float radious;

    bool onRadius;
    public bool umaVez = true;

    public GameObject inimigoTeste;

    private CaixaDialogoControl dc;

    private void Start()
    {
        dc = FindObjectOfType<CaixaDialogoControl>();
    }

    public void FixedUpdate()
    {
        //Interact();
    }

    private void Update()
    {
        if(/*onRadius*/ inimigoTeste == null && umaVez == true)
        {
            Invoke("Escrever", 0.5f);
            umaVez = false;
        }
    }

    /*public void Interact()
    {
        Collider2D hit = Physics2D.OverlapCircle(transform.position, radious, playerLayer);

        if(hit != null)
        {
            onRadius = true;
        }
        else
        {
            onRadius = false;
        }
    }*/

    private void OnDrawGizmosSelected()
    {
        Gizmos.DrawWireSphere(transform.position, radious);
    }

    void Escrever()
    {
        dc.Speech(profile, speechText, actorName);
    }
}

And here is the code for the Control Dialog Box:

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

public class CaixaDialogoControl : MonoBehaviour
{
    public GameObject dialogObj;
    public Image profile;
    public Text speechText;
    public Text actorNameText;

    public float typingSpeed;
    private string[] sentences;
    private int index;

    public GameObject inimigoTeste;
   
    public bool testeTutorial = true;
    public bool umaVez = true;

    public GameObject Joystick;
    public GameObject ButtomTiro;

    public Animator animCaixa;
    public Animator anim;

    void Update()
    {
        if(inimigoTeste == null)
        {
            Joystick.SetActive(false);
            ButtomTiro.SetActive(false);
            Invoke("ChamarCaixaDialogo", 0.01f);

            if(testeTutorial == true && umaVez == true)
            {
                Invoke("ChamarInstrutor", 4.0f);
                umaVez = false;
            }
        }
    }

    public void Speech(Sprite p, string[] txt, string actorName)
    {
        profile.sprite = p;
        sentences = txt;
        actorNameText.text = actorName;
       
        if(inimigoTeste == null)
        {
            StartCoroutine(TypeSentence());   
        }
       
    }

    void ChamarCaixaDialogo()
    {
        animCaixa.SetBool("Parado", false);
        animCaixa.SetBool("Ativar", true);
        animCaixa.SetBool("Desativar", false);
    }

    void ChamarInstrutor()
    {
        anim.SetBool("Parado", false);
        anim.SetBool("Ativar", true);
    }

    IEnumerator TypeSentence()
    {
        foreach (char letter in sentences[index].ToCharArray())
        {
            speechText.text += letter;
            yield return new WaitForSeconds(typingSpeed);
        }
    }

    public void NextSentence()
    {
        if(inimigoTeste == null)
        {
            if(speechText.text == sentences[index])
            {  
                //ainda há textos
                if(index < sentences.Length - 1)
                {
                    index++;
                    speechText.text = "";
                    StartCoroutine(TypeSentence());
                }
                else //lido quando acaba os textos
                {
                    speechText.text = "";
                    index = 0;
               
                    animCaixa.SetBool("Parado", false);
                    animCaixa.SetBool("Ativar", false);
                    animCaixa.SetBool("Desativar", true);
                }
            }   
        }
    }
}

Here is the video I saw:

If anyone can help me how to make the Player and NPC speak I would be very grateful, because I’ve been at it for HOURS.

Or if anyone has a simpler idea of how to make a dialogue system please tell me because I don’t know what else I can do ;-;

Step one for building anything is to first design it. That is, to describe—in words, pictures, or both—exactly what it does. Then you want to write out a description of how you think it should do it.

Unfortunately, “a dialog system” is not specific enough. Consider how many different kinds of dialog system might be possible, from simple to complicated. Coding is translation work: from idea to reality. You cannot translate a vague idea into a real thing. You can only translate a very specific idea.

A dialog system may be a sequence of alternating statements, with different options leading to different sets of statements. This could be represented by a tree. A dialog tree will grow very large, if you have a lot of options. If you have a lot of different characters, you will need a lot of different trees: one for each character.

Dialog requires a lot of text—text is data. Usually you wouldn’t store it in source code, but in some kind of resource file. You would want to separate the logic—code—from the data, so you can re-use the code. A dialog controller would find and load the correct tree based on the character, by id or name.

Anyway, my point is not to solve your problem for you, but to encourage you to write down, in sufficient detail, the specific nature of the problem—what you want your dialog system to do—and then a strategy for how to do it. Then you can start to translate that into code. If you don’t do it explicitly, you are doing it implicitly. But implicit things are much harder to think about, to analyze, and to improve, than explicit things.