Applying Force to Game Objects with Tag Errors.

Hi there,

I’m still quite new at coding and have been trying for hours now to figure out how to get this part of my code to work.
Basically I’m rolling a ball over a collider (containing this script), the collider then destroys a wall by adding a force to everything tagged with ‘DestroyBrick’. I’ve tried several different ways of writing the code and looked on here for answers as well as tutorials and scripts but so far not managed to figure out what is wrong exactly.

It’d be great if someone could point me in the right direction with this, thanks in advance!


public class Destroy_Bricks : MonoBehaviour 
{
	public float DestroyForce = 5000f;
	public GameObject[] DBR;
	public GameObject DBRobj 

	// Use this for initialization
	void Start () 
	{


		DBR = GameObject.FindGameObjectsWithTag("DestroyBrick");
		for (int i = 0; i < DBR.Length; i++);			
	}

	void OnTriggerEnter (Collider other) // make sure object has IS TRIGGER ticked!!!
	{

		for (DBRobj in DBR)
		{
		DBRobj.rigidbody.AddForce(-transform.forward * DestroyForce, ForceMode.Acceleration);
		}
	}

}

public class Destroy_Bricks : MonoBehaviour
{
public float DestroyForce = 5000f;
private GameObject DBR;

    // Use this for initialization
    void Start () 
    {
       DBR = GameObject.FindGameObjectsWithTag("DestroyBrick");    
    }
 
    void OnTriggerEnter (Collider other) // make sure object has IS TRIGGER ticked!!!
    {
       foreach (GameObject DBRobj in DBR)
       {
          DBRobj.rigidbody.AddForce(-transform.forward * DestroyForce, ForceMode.Acceleration);
       }
    }
}