Need help with limited shots

Hello, i need some help, i’m using a shooting-script for my game and want to have limited shots for it.

using UnityEngine;


public class WeaponScript : MonoBehaviour
{
	//--------------------------------
	// 1 - Designer variables
	//--------------------------------
	
	
	public Transform shotPrefab;
	

	public float shootingRate = 0.25f;
	
	//--------------------------------
	// 2 - Cooldown
	//--------------------------------
	
	private float shootCooldown;
	
	void Start()
	{
		shootCooldown = 0f;
	}
	
	void Update()
	{
		if (shootCooldown > 0)
		{
			shootCooldown -= Time.deltaTime;
		}
	}


	public void Attack(bool isEnemy)
	{
		if (CanAttack)
		{
			shootCooldown = shootingRate;
			
			// Create a new shot
			var shotTransform = Instantiate(shotPrefab) as Transform;
			
			// Assign position
			shotTransform.position = transform.position;
			
			// The is enemy property
			ShotScript shot = shotTransform.gameObject.GetComponent<ShotScript>();
			if (shot != null)
			{
				shot.isEnemyShot = isEnemy;
			}
			
			MoveScript move = shotTransform.gameObject.GetComponent<MoveScript>();
			if (move != null)
			{
				move.direction = this.transform.right; // towards in 2D space is the right of the sprite
			}
		}
	}
	
	
	public bool CanAttack
	{
		get
		{
			return shootCooldown <= 0f;
		}
	}
}

If you are looking for a magazine you can just store the amount of shots you can shoot in an int and then check if you have any shots left when you want to shoot. If you are looking for a way to limit the amount of shot that can be in the game at once i would store the shot in fire in an int and then when a shot is destroy reference back to the weapon script and remove one fromt the int that store the shots.

I hope this helps in anyway.