[Help!] C# problems... Please help!

I am currently working on a C# script and when I run the game console will appear saying “Object reference not set to an instance of an object.”

This is where it says it. The whole second line.

//Add spheres that can be collided against 
        GameObject[] sp2 = GameObject.FindGameObjectsWithTag ("Softbody");  
        Object[] objs = GameObject.FindObjectsOfType(typeof(GameObject)); 
        allSpheres = new ArrayList(); 
        int cnt=0; 
        for(int i=0;i<sp2.Length;i++) { 
            allSpheres.Add(sp2[i]); 
            cnt++; 
        } 
        for(int i=0;i<objs.Length;i++) 
        {          
            if(objs[i].name == "SphereSoft") {    
                allSpheres.Add(objs[i]); 
                cnt++; 
            } 
            
        }

What I wanna know is what that means and how I can fix it.

Try this:

GameObject[ ] gobjs = FindObjectsOfType();

where would I put the name of the game object? Because if I don’t have the name, it won’t recognize the array list: allSpheres.

Is there a possibility that one of your arrays there is not finding anything and is thus staying null? Try checking to see if it’s not null before doing your for loops?