SetInt to a fixed value?

Hi!
I’m having trouble taking away ALL bullets from the player in my script and leave him with 1 Bullet.
The way my bullets script work so far is this:

GunScript

        if (controls.Player.Fire.triggered && canShoot) 
        {

            if (PlayerPrefs.GetInt("handGunBulletTemp") >= 1)
            {
                HandGunShoot();
            }
        }

    public void HandGunShoot()
    {
        GameManager.Instance.minusHandGunBullet();
    }

GameManager

    public int handGunBullet;
    public Text handGunBulletText;

    public void minusHandGunBullet()//Called from GunScript
    {
    PlayerPrefs.SetInt("handGunBulletTemp", PlayerPrefs.GetInt("handGunBulletTemp") - 1); // Minus one bullet.
    handGunBulletText.text = PlayerPrefs.GetInt("handGunBulletTemp").ToString(); //Update the text
    }

Quite simple but I want to press a button and no matter how many bullets the player have, he will only be left with one bullet… Is that possible?

Thankful for any advice or help!

its hard to understand what you want but if i take your words literally:

  if (Input.GetKeyDown(KeyCode.U))
        {
         PlayerPrefs.SetInt("handGunBulletTemp", 1); 

        }
1 Like

^
Thats exacly what I was looking for! I tried, =< 1, <= 1, == 1 -+ 1 and all types of combos… Stupid me >_<