So I have a gun, right. But the thing is, I want to create an ammo gui, and I want there to be a max ammo. The only poblem I have with making the max ammo thing I have is finding out how much ammo I subtract from the counter. Like you could do
maxAmmo = 270
maxAmmo = maxAmmo - 30 --//30 = amount of rounds in a mag
But then even if I had, let's say, 21 rounds in a mag, and only need to subtract 9 from the Max Ammo Counter, it would still subtract 30. You could also make it so that you can only reload when you have 0 ammo, which would look like this
maxAmmo = 270
ammo = 30
if ammo == 0 then
maxAmmo = maxAmmo - 30
end
But that would be annoying, because if you wanted a full mag, you would have to waste the rounds in the mag to reload.
For another example, let's say I had 24 rounds in the magazine, and the Max Ammo Counter has 270 rounds left, I would only need to subtract 6 rounds from the counter, but I am unsure on how to calculate this.
Does anyone know how to calculate this? I've seen games like arsenal or Phantom Forces do it.
Thanks in advance, Zander.

8 comments
I can't visualize what your goal is. Please show examples... Why suddenly 9?
Bruh, do you mean add?
Does my last example give you a better understanding?
Feahren, If I only had 24 rounds in the mag, I only want to add 6 rounds to my magazine (Fill it to capacity), and subtract 6 rounds from the max ammo counter (270).
No, I don't understand what you mean by subtract, what equilibrium are you trying to reach?
So, like I said, I have 24 rounds in my gun magazine, then, I have 270 rounds in reserve. I want to change the amount of bullets in the magazine 30, while subtracting 6 rounds (the amount of rounds I put unto the mag) from 270 (the reserve amount).
Ah, that's much easier. Simple enough, let me whip that up for you.
Thank you so much!