How do you spawn objects based on a variable

I want to spawn mags based on the amount of variable mags I have left. Like if I have 1 mag then 1 mag appears but if I have 2, then 2 appear. This is my code : using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class shooting : MonoBehaviour
{

public double magbullets = 10;
public double mags = 2;

public Transform bulletSpawnPoint;
public GameObject bulletPrefab;

public Transform spawnLocation;




public float speed = 1f;
// Start is called before the first frame update
void Start()
{
    
}

// Update is called once per frame
void Update()
{
    




    if (Input.GetKey(KeyCode.R))
    {
        if (mags > 0)
        {
            if (magbullets < 1)
            {

                mags -= 1;
                magbullets += 10;
                GetComponent<Animation>().Play("reload");
            }
        }
    }

    if (Input.GetMouseButtonDown(0))
    {
        if (magbullets > 0)
        {
            
            var bullet = Instantiate(bulletPrefab, bulletSpawnPoint.position, bulletSpawnPoint.rotation);
            bullet.GetComponent<Rigidbody>().velocity = bulletSpawnPoint.forward * speed;
            magbullets -= 1;
            
        }
    }
    

}

}

A quick solution is a for i in range setup then use a list or iterations to give different spawn points

for (int i = 0; i < magsLeft; i++)
{
    Instantiate(magGO, spawnLocation.transform.position);
}

what is magGo? When I remove it, it says that UnityEngine.Vector3 cannot be used as parameter type ‘T’

magGO is the gameobject for the mags. the error is because I misread your code, it should only be spawnLocation not spawnLocation.transform.position.

what’s the I for?

Int I is the customary variable used to iterate through the sequence increasing by 1 every time until you reach the desired number of iterations.