How do I get my weapon to stop firing if the ammo <= 0

void Update () {
if (Input.GetButton(“Fire1”))
{
//if ammo <= 0 then the weapon can’t fire.*************************************

        // create a new projectile in the world
        GameObject projectileLazerInstance = GameObject.Instantiate(ProjectileLazer);
    
        //Position the lazer below the player
        Vector3 newLocation = transform.position - transform.up * ProjectileOffset;
        projectileLazerInstance.transform.position = newLocation;

        //Fire the lazer
        Rigidbody projectileLazerRB = projectileLazerInstance.GetComponent<Rigidbody>();
        projectileLazerRB.AddForce(transform.forward * ProjectileForce);
    }

I’d suggest looking at some basic c# tutorials to understand the logic. TutorialsPoint runs a great gig.

But here is your solution, the return keyword will make the compiler jump back up to the top of the function without executing the rest of the function.

if(ammo <= 0)
return; // Skips the rest of the code 

Let me know if it didn’t work / You need further Help