Prevent player from moving in a certain direction while moving in another

Hi. I am making a Tron light-cycle game and I having some trouble figuring how to stop the player from moving on the opossite direction that he is already moving. Right now I am creating a colored square on each change of direction and between them I create the light wall, the problem occurs when I am moving in a single direction since I just have one colored square of the two I need to create a solid wall with fitColliderBetween, the light wall behind the player is not solid yet and the player can move freely up and down the wall until he hits the last colored square used to initiate the fitColliderBetween or until he moves again in the direction he was facing initially and hit the square created when he turned in the opossite direction that he was moving. This can be prevented by disabling the input for moving in the undesired direction. If the player is moving UP, he should not move DOWN but he can choose to move RIGHT or LEFT.

If there a way to disable the player input for a single direction? In this case the opposite one. I already have a way of telling which way the player is facing (used to spawn projectiles) but I do not know how to disable a single input, I found similar answers but they wanted to disable all player input while keeping the player’s momentum and I just want to disable only one direction.

public enum PlayerFacing

public PlayerFacing facing;

// Use this for initialization
void Start () {
	//Initial velocity so it starts moving
	GetComponent<Rigidbody2D> ().velocity = Vector2.up * speed;
	spawnWall ();


// Update is called once per frame
void Update () {
	if (Input.GetKeyDown (upKey)) {
		// Do is key pressed
		GetComponent<Rigidbody2D> ().velocity = Vector2.up * speed;
		//Spawn wall
		spawnWall ();
		facing = PlayerFacing.UP;
	} else if (Input.GetKeyDown (downKey)) {
		GetComponent<Rigidbody2D> ().velocity = -Vector2.up * speed;
		spawnWall ();
		facing = PlayerFacing.DOWN;
	} else if (Input.GetKeyDown(rightKey)) {
		GetComponent<Rigidbody2D> ().velocity = Vector2.right * speed;
		spawnWall ();
		facing = PlayerFacing.RIGHT;
	} else if (Input.GetKeyDown (leftKey)) {
		GetComponent<Rigidbody2D> ().velocity = -Vector2.right * speed;
		spawnWall ();
		facing = PlayerFacing.LEFT;
	}else if (Input.GetKeyDown (shotKey) && Time.time > nextFire) {
			nextFire = Time.time + fireRate;
		//Instantiate (basicshot, bulletSpawn.position, Quaternion.identity);
		BasicShoot (basicshot, 150);

		// Fill between walls
		fitColliderBetween (wall, lastWallEnd, transform.position);

Just add a variable to keep track of your direction and add a condition in your input verification

// Create an enum and simply cache your direction in a variable
public enum Direction {
    Left, Right, Up, Down
public Direction currentDirection;

// And then update currentDirection appropriatly in update and check it
if (Input.GetKeyDown(upKey) && currentDirection != Direction.Down) {
    // your movement code here
    currentDirection = Direction.Up;
} else if ...

also i suggest you to cache your rigidbody2D in a variable instead of refetching it in every update.