NullReferenceException ?? How to fix this ?

Hello, can somebody please help ?

Here is the error :

NullReferenceException: Object reference not set to an instance of an object

public void Save()
{
Objects = 0;
objects = GameObject.FindGameObjectsWithTag(“WeedPlant”);

        for (int i = 0; i < objects.Length; i++)
        {
            xPos[Objects] = objects*.gameObject.transform.position.x;*

yPos[Objects] = objects*.gameObject.transform.position.y;*
zPos[Objects] = objects*.gameObject.transform.position.z;*
fert[Objects] = objects*.GetComponent().Fert; // ERROR*
IsGrown[Objects] = objects*.GetComponent().isGrown; // ERROR*
Grams[Objects] = objects*.GetComponent().WeedQuant;*
procces[Objects] = objects*.GetComponent().pro;*
water[Objects] = objects*.GetComponent().Water;*
plantType[Objects] = objects*.GetComponent().PlantType;*

Objects++;
}
}
And the save Script :
* public void Save () {*
BinaryFormatter binary = new BinaryFormatter();
FileStream fStream = File.Create(Application.persistentDataPath + “/SaveFile1.dat”);
SaveManager saver = new SaveManager();
saver.money = MoneyScript.money;
saver.farmBrought = BuyFarm.FarmBrought;
saver.weedOnHand = Inventory.weedOnHand;
saver.bucket = Inventory.BucketBrought;
saver.shovel = Inventory.ShovelBrought;
saver.grams = Inventory.Grams;
saver.objects = PlantWeed.Objects;
saver.x = PlantWeed.xPos;
saver.y = PlantWeed.yPos;
saver.z = PlantWeed.zPos;
saver.weedQuant = PlantWeed.Grams;
saver.isGrown = PlantWeed.IsGrown;
saver.ferti = PlantWeed.fert;
saver.pro = PlantWeed.procces;
saver.Water = PlantWeed.water;
saver.PlantType = PlantWeed.plantType;
saver.isReal = LevelManager.IsReal;
saver.objOnField = RestrictedZone.ObjOnField;

binary.Serialize(fStream, saver);
fStream.Close();
* }*

public void Load ()
{
if (!StartNew)
{
if (File.Exists(Application.persistentDataPath + “/SaveFile1.dat”))
{
BinaryFormatter binary = new BinaryFormatter();
FileStream fStream = File.Open(Application.persistentDataPath + “/SaveFile1.dat”, FileMode.Open);
SaveManager saver = (SaveManager)binary.Deserialize(fStream);
MoneyScript.money = saver.money;
BuyFarm.FarmBrought = saver.farmBrought;
Inventory.weedOnHand = saver.weedOnHand;
Inventory.BucketBrought = saver.bucket;
Inventory.ShovelBrought = saver.shovel;
Inventory.Grams = saver.grams;
PlantWeed.Objects = saver.objects;
PlantWeed.xPos = saver.x;
PlantWeed.yPos = saver.y;
PlantWeed.zPos = saver.z;
PlantWeed.Grams = saver.weedQuant;
PlantWeed.IsGrown = saver.isGrown;
PlantWeed.fert = saver.ferti;
PlantWeed.procces = saver.pro;
PlantWeed.water = saver.Water;
PlantWeed.plantType = saver.PlantType;
LevelManager.IsReal = saver.isReal;
RestrictedZone.ObjOnField = saver.objOnField;

fStream.Close();
Objects = 0;
objects = GameObject.FindGameObjectsWithTag(“WeedPlant”);

for (int i = 0; i < objects.Length; i++)
{
Destroy(objects*);*

Objects++;
}
}
}
}
}
[Serializable]
class SaveManager
{
public int money;
public bool farmBrought;
public bool bucket;
public bool shovel;
public int[] weedOnHand;
public int grams;
public int objects;
public float[] x;
public float[] y;
public float[] z;
public bool[] isGrown;
public int[] weedQuant;
public int[] pro;
public int[] Water;
public int[] PlantType;
public bool isReal;
public int[] ferti;
public int objOnField;
}

NullReferenceException is because something wasn’t assigned and it’s trying to use it… But nothing is there.

From your code:
GameObject.FindGameObjectsWithTag(“WeedPlant”);

Are you sure you have objects that are ACTIVE and tagged with “WeedPlant”? Not named, but actually tagged? I didn’t even look at the rest of your code, but you should make sure that that things are properly being assigned.

When you use Find… The object needs to be ACTIVE within the scene.

So, if i dont have any objects wth WeedPlant tag it will show this right ?
I can add IF statment that will cancel this script if there arent any of thoes objects right ?