Removing Player Input/Movement Functionality C#

Hi,

Currently developed an open and close chest scenario to loot from, the GUI pauses the game whilst the player is interacting them; however whilst the “open” animation is being played it allows the player to move freely; I want this to stop as it causes scenarios such as the player to run whilst its opening and then accessing it or crashing from afar.

Code:

private IEnumerator Open()
	{	
		animation.Play("Open");
		ParticleEffects.active = true;
		audio.PlayOneShot(OpenSound);
		yield return new WaitForSeconds(animation["Open"].length);
		
		Time.timeScale = 0f;

Is there anything I can do to to A) remove player input whilst the state is “Open” or adjusting the animation?

Cheers

Why not set a boolean on the Player Control script, like

private bool FreezeControls

set it to true and in the Update for the player movement controls simply check

like

private bool FreezeControls = false;

void Update(){
if (!FreezeControls){
DoMoveForward;
DoMoveBackwards;
etc
}
}

How would i call this “freezecontrol” if its a private?

i.e. i’ve put that in the movement script; but if “open” then FreezeControls? as these are within 2 seperate scripts?