bullets in fps

so i was thinking of a script should be easy but i cant find a way so that when my gun reloads it add only the amount i need to my gun like i have 20/200 i use 8 bullets 12/200 but i dont want just to add 8 like if(b < 20) add 20 like that i want it to only add 8 or 2 or 12 any thoughts

I really don’t understand what you want. Next time you ask for online help, please construct your question so that we can understand and help you.

as chubbspet said, Is hard to understand what u wanna do.

well, I give u my guess.
U have a magazine at maximum of 20 bullets… and maximum bullets storage at 200 pieces.
Let’s say u used 8 bullets, and left 12/200.
When u “Reload”:

Option 1 (Reload by bullets count):
BulletsToReload = maxMagazine - currentMagazine (8 = 20-12)
BulletsInStorage = BulletsInStorage - BulletsToReload (192 = 200-8)
currentMagazine = currentMagazine + BulletsToReload (20 = 12+8)
**RESULT → (20/192)

Option 2 (Reload by magazine count):
BulletsToReload = maxMagazine (20 = 20)
BulletsInStorage = BulletsInStorage - BulletsToReload (180 = 200-20)
currentMagazine = BulletsToReload (20 = 20)
**RESULT → (20/180)

i want to do option 1 but how would i do that i can just put

var bullets = 20;
var ammo = 200;

void update ()
{
if (inputmousedown(0))
{
bullets += 1;
ammo -= 1;
}
}

wouldn’t this take like 8 clicks to get 20/192

lol i think you just gave me the answer in the option 1

var currentBullets = 20;
var magazineMax = 20;
var bullets = 200;
var amountToRefill;

void update () {
	if (inputmousedown(0)) {
		// Gets the amount needed for a full magazine
		amountToRefill = magazineMax - currentBullets;
		if (bullets <= 0) {
			// The player has no more bullets
			Debug.Log("You don't have anymore bullets!");
		} else if (bullets > 0  bullets < amountToRefill) {
			// The player has less bullets than is required to fill the magazine
			currentBullets += bullets;
			bullets = 0;
		} else {
			// Fills the magazine and removes the amount from the players bullet pouch
			currentBullets = magazineMax;
			bullets -= amountToRefill;
		}	
	}
}

Try this. This will do what you want in one click.

lol not var int but thats fine i got it tyvm :stuck_out_tongue: