Generator script not working due to lack of differentiation?

Hello, I have a generator script that basically generates the bulk of the objects in my game, but It is not differentiating between generating 100 stone or 100 grass, it simply generates about 50 of both. Thus far I have been unsuccessful of finding out how to deal with this due to me not being good at using multiple arrays in cooperation with each other. Thanks.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EcoGeneraterScript : MonoBehaviour {

	public GameObject Map;
	public GameObject[] GeneratedObjects;

	public int[] NumberofObjectsToGenerate;

	private float Cord_X = 0;
	private float Cord_Z = 0;

	private bool CanGenerate = true;

	void Update () {
		for ( int i = 0; i < NumberofObjectsToGenerate.Length; i++) {
			foreach (GameObject GeneratedGameObject in GeneratedObjects) {
				if (NumberofObjectsToGenerate *> 0 && CanGenerate == true) {*
  •  			Instantiate(GeneratedGameObject, new Vector3(Cord_X, 0.5f, Cord_Z),Quaternion.identity);*
    

_ NumberofObjectsToGenerate -= 1;_
* Cord_X += 1;
if (Cord_X >= 100) {
Cord_X = 0;
Cord_Z += 1;
if (Cord_Z >= 100) {
_
CanGenerate = false;_
_
}_
_
}_
_
}_
_
}_
_
}_
_
}_
_
}*_

The logic of your foor loops is not correct. There is no loop in your code that iterates the number of times indicated by each entry in your NumberofObjectsToGenerate array. What you’re doing right now is instantiating one of every object in your GeneratedObjects array for every entry in your NOTG (yeah that’s what I’ll call NumberofObjectsToGenerate, from now on). So if your NOTG array has 7 entries then your code will spawn 7 of each (unless of course the condition of CanGenerate is false).

//Here's an assumption I'm making about your arrays since you didn't described their contents
//    Array Position    Array Name    Entry       Array Name        Entry
//              0           NOTG       50        GeneratedObjects   Obj1
//              1           NOTG       100      GeneratedObjects   Obj2
//So I'm assuming that what you want to do is link the arrays by their position, meaning that
//you want to spawn 50 of Obj1 and 100 of Obj2 
//since the position in their respective array is the same
//So to do that I'd do something like this:
void Update(){
    for(int i = 0; i<NOTG.Length ; i++){
        //Copy the number since for some reason you want to decrease it while iterating
        //Know that modifying an array or any collection while iterating over it,
        //isn't always the best idea
        int numberOfInstances = NOTG*;*

for(int j = 0; j<numberOfInstances; j++){
Instantiate(GeneratedObjects*, new Vector3(Cord_X, 0.5f, Cord_Z),Quaternion.identity);
NOTG –;
_}
}
}*
And that’s it. A couple of notes. First, never do this type of boolean comparison CanGenerate == true, it is completely redundant, like multiplying a number by 1, there is no logical reason to do it. Second, you don’t need to check if the number inside NOTG is greater than zero (NumberofObjectsToGenerate _> 0) because if you will use that number to iterate, but it is zero, there will simply be zero iterations and the code won’t spawn anything, it is a bit redundant to do that check too. And finally you can see that I didn’t include the CanGenerate stuff, well that’s because I don’t completely understand where you were going with that so I didn’t want to mess with it, you can include that part yourself.

Hope this helps!
Edit: Corrected the Instantiate line