Do not pick item when item full

Im looking a way for my player does not pick medikit or ammo during he has a full health and a full ammo. What is the best way to do? Should I use loops to solve the problems?

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

public class PlayerPickUpBullet : MonoBehaviour {

    PlayerShoot playerShoot;

    public int bulletPickUp;
	
	void Start ()
    {
        playerShoot = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerShoot>();
	}

    void OnTriggerEnter2D(Collider2D other)
    {
        if(other.gameObject.tag == "Player")
        {
            other.gameObject.GetComponent<PlayerShoot>().PickUpBullet(bulletPickUp);
            Destroy(gameObject);
            Debug.Log(" bullet " + playerShoot.currentBullet);
        }
    }
}

OOP here is not the best, so the thing you need obviously is the state of the player. Inside player you would have value of health and bullet, if it is equal to defined max then you won’t pick or pick a part depends on your requirements.
ex.

    PlayerController {
        int ammo = 0;
        int health = 100;
    }
    
    // wherever you have collission handling you would have to do sth like
   // MAX_AMMO is another variable which you  have to place somewhere, like GameConstants static 
   // class or sth like that. It is your choice
    if ( ammo == MAX_AMMO) {
     // do not destroy object - not picking up
    } else {
    // pick ammo - add desired number to ammo player - and destroy ammo object in the scene
    }

I have found a solution for a long time ago. First, we write the PickUp Item script. For this case, we are going to write the PlayerPickBullet.

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

public class PlayerPickUpBullet : MonoBehaviour {

    PlayerShoot playerShoot;

    public int bulletPickUp;
	
	void Start ()
    {
        playerShoot = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerShoot>();
	}

    void OnTriggerEnter2D(Collider2D other)
    {
        if(other.gameObject.tag == "Player")
        {
            other.gameObject.GetComponent<PlayerShoot>().PickUpBullet(bulletPickUp);
            Destroy(gameObject);
            //Debug.Log(" bullet " + playerShoot.currentBullet);
        }
    }
}

Now we write/modify a player’s stats in the PlayerShoot script.

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

public class PlayerShoot : MonoBehaviour {

    PlayerPickUpBullet playerPickUpBullet;

    Animator animator;
    Rigidbody2D bullet;

    public Transform rifle;
    public GameObject projectile;
    public Slider bulletSlider;

    [HideInInspector] public Vector2 offset = new Vector2(0.4f,0f);
    public Vector2 velocity;
    public float cooldown = 1f;
    public float bulletdied = 1f;

    [HideInInspector]
    public bool canShoot = true;

    public int maxBullet;
    [HideInInspector] public int currentBullet;

    void Start ()
    {
        playerPickUpBullet = GetComponent<PlayerPickUpBullet>();

        animator = GetComponent<Animator>();
        bullet = GetComponent<Rigidbody2D>();
        currentBullet = maxBullet;
    }

	void Update ()
    {
        if(currentBullet <= 0)
        {
            return;
        }
        Shoot();    
    }

    public void PickUpBullet(int pickupbullet)
    {
        currentBullet += pickupbullet;
        bulletSlider.value = currentBullet;
        //set the bullet limit
        if (currentBullet > maxBullet)
        {
            currentBullet = maxBullet;
        }

    }

    public void Shoot()
    {
        if (Input.GetMouseButtonDown(0) && canShoot)
        {            
            GameObject go = Instantiate(projectile, (Vector2)rifle.transform.position + offset * transform.localScale.x, Quaternion.identity);
            go.GetComponent<Rigidbody2D>().velocity = new Vector2(velocity.x * transform.localScale.x, velocity.y * transform.localScale.y);
            currentBullet--;
            bulletSlider.value = currentBullet;
            Destroy(go, bulletdied);
            animator.SetTrigger("shoot");
            //Debug.Log(" player bullet left " + currentBullet);
        }
    }
}