How to stop an Integer from going negative and from going over a limit?

You have to do a check and control it when close to the minimum or maximum ranges.

First example let’s consider maximum value. You want a maximum amount of ammo to be 99. Let’s also say for this example that you can gain ammo in increments of 1 or 5 only. You must clamp your int maximum value at 98 NOT 99. 98 + 1 = 99 and the minimum ammo you can pick up is going to be 1. But what happens if you have 98 ammo and you pick up 5? Yes you will go over the maximum value and end up with 103 ammo. To control this you must use a branch. First check is the value <= 94? if true then +5 like normal. If false then set ammo 99 explicitly. Once you set the value to 99 you are in the clamp zone and no more ammo can be picked up. Because you already clamped the value to 98 you won’t need to do this for picking up single ammo as mentioned before 98 + 1 = 99 the target maximum value.

What about ammo depletion? What if there is an instance where an amount of ammo higher than 1 can be consumed? Let’s run this idea in reverse. Say you can consume 1 or 5 ammo at a time. Clamp the int minimum value at 1 because like before 1 - 1 = 0 but 1 - 5 = -4 so we will end up with 4 below the target minimum value. To avoid this add a check again when consuming ammo in multiples of 5. Treat any value <5 as 0 ammo by again asking is the value => 5 and if true allow the ammo to be consumed. If false do nothing simple as that. When using single ammo it will consume ammo to 0.

The attached image of my blueprint shows how to control the +5 increase. This example is for castlevania style hearts where a player can pick up 1 or 5 at a time. In the example I am using an event so that when G is pressed it acts like the player has gained 5 hearts.