How can I make the player stop moving when a UI dialogue box is active?

Ok so I am a beginner at c# and was wondering how to make it so that when a dialogue box appears on the screen, the player can not move at all. I am doing a 2D top-down RPG game, and I have a nice dialogue, and movement script. I would also like to mention that I made a pause menu and figured out how to stop the player from moving when the pause menu is up, but I cant do the same with this dialogue box.

Here’s my dialogue script:

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

public class Dialougue : MonoBehaviour
{
public TextMeshProUGUI textComponent;
public string lines;
public float textSpeed;

private int index;

// Start is called before the first frame update
void Start()
{
    textComponent.text = string.Empty;
    StartDialouge();
}

// Update is called once per frame
void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        if (textComponent.text == lines[index])
        {
            NextLine();
        }
        else
        {
            StopAllCoroutines();
            textComponent.text = lines[index];
        }
    }
}

void StartDialouge()
{
    index = 0;
    StartCoroutine(TypeLine());
}

IEnumerator TypeLine()
{

    foreach (char c in lines[index].ToCharArray())
    {
        textComponent.text += c;
        yield return new WaitForSeconds(textSpeed);
    }

}

void NextLine()
{
    if (index < lines.Length - 1)
    {
        index++;
        textComponent.text = string.Empty;
        StartCoroutine(TypeLine());
    }
    else
    {
        gameObject.SetActive(false);
    }
}

}

And here is my player movement script:

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

public class PlayerMovement : MonoBehaviour
{

public float moveSpeed = 5f;

public Rigidbody2D rb;
public Animator animator;

Vector2 movement;

public VectorValue startingPosition;

void Start()
{
    transform.position = startingPosition.initalValue;
}

void Update()
{
    

    if (!PauseMenu.isPaused)
    {
        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");

        animator.SetFloat("Horizontal", movement.x);
        animator.SetFloat("Vertical", movement.y);
        animator.SetFloat("Speed", movement.sqrMagnitude);
    }
    
}

void FixedUpdate()
{
    rb.MovePosition(rb.position + movement.normalized * moveSpeed * Time.fixedDeltaTime);
}

}

Please, any help will be appreciated. I feel like this has a simple solution that I just don’t know.

Basicaly you need to disable movement script.
Place this code where you starting the dialogue

gameObject.Find("PLAYER GAME OBJECT NAME OR GAMEOBJECT WITH MOVEMENT SCRIPT ATTACHED TO").GetComponent (PlayerMovement). enabled = false;

And this where you end the dialogue

gameObject.Find("PLAYER GAME OBJECT NAME OR GAMEOBJECT WITH MOVEMENT SCRIPT ATTACHED TO").GetComponent (PlayerMovement). enabled = true;

Hope this will help

Here’s an idea. Add a boolean that is false by default. When the dialogue pops up, have the boolean set to true, and false when the dialogue disappears. Then, only let the player move if the boolean is false.