WaitForSeconds not working

Wait for Seconds is not compiling I keep getting Unexpected symbol ‘(’ expecting …

using UnityEngine;
using System.Collections;

public class Block_DestroyCollision : MonoBehaviour 
{
	// Use this for initialization
	void Start () 
	{

	}

	// Update is called once per frame
	void Update () 
	{
		if (Input.GetKey (KeyCode.Space)) 
		{
			var playerObject = GameObject.Find ("MainPlayer");
			Vector2 playerPos = playerObject.transform.position;
			//Debug.Log (playerPos);// display position of player (x,y) on console.
			var blockObject = GameObject.Find ("blocks1_3");
			Vector2 blockPos = blockObject.transform.position;
			float PlayerDistancex;
			PlayerDistancex = Vector2.Distance (playerPos, blockPos);
			//Debug.Log (PlayerDistancex); // display absolute value distance from block on console.
			if (PlayerDistancex < 3)
			{
				Destroy (GetComponent<BoxCollider2D>());
				Delay ();
			}
			
				
		}
	}
	public static void Delay ()
	{
		yield WaitForSeconds (10);
		gameObject.AddComponent("BoxCollider2D");
	}
}

The way you’ve written works in JS, but in C# it must be:

yield return new WaitForSeconds(10);

But there are other errors that will drive you nuts! WaitForSeconds only pauses coroutines, thus Delay can’t be a regular function; the code will be executed while space is pressed, thus you will get null reference errors after the first time (GetComponent will return null after the box collider has been destroyed). Basically, this code could be re-written like this:

using UnityEngine;
using System.Collections;
 
public class Block_DestroyCollision : MonoBehaviour 
{

    GameObject playerObject; // find the player only once
    GameObject blockObject; // find the block only once

    void Update () 
    {
       // don't run this code while Delay is executing:
       if (Input.GetKey(KeyCode.Space) && !waiting) 
       {
         if (!playerObject) playerObject = GameObject.Find ("MainPlayer");
         Vector2 playerPos = playerObject.transform.position;
         //Debug.Log (playerPos);// display position of player (x,y) on console.
         if (!blockObject) blockObject = GameObject.Find ("blocks1_3");
         Vector2 blockPos = blockObject.transform.position;
         float PlayerDistancex;
         PlayerDistancex = Vector2.Distance (playerPos, blockPos);
         //Debug.Log (PlayerDistancex); // display absolute value distance from block on console.
         if (PlayerDistancex < 3)
         {
           Destroy (GetComponent<BoxCollider2D>());
           StartCoroutine(Delay ());
         }
       }
    }

    bool waiting; // tells whether the delay is running

    IEnumerator Delay ()
    {
       waiting = true; // Delay started
       yield return new WaitForSeconds (10);
       gameObject.AddComponent("BoxCollider2D");
       waiting = false; // Delay ended
    }
}