Global variable of ammo


#1

I want to make an ammunition variable. How do I make that, when it get’s to zero, you can’t shoot again (stop from substracting)?
Edit: I mean, I want to prevent this:
this


#2

In the event that fires the bullet and decreases the ammunition variable, add a condition to check that the ammunition variable is greater than 0.


#3

It works, but it stops in -1


#4

Sounds like the condition to check isn’t correct or there is something outside the condition changing the variable.

Are you able to share a screenshot of the section in question?


#5

Here:


#6

Why are you subtracting 2?

To get to -1 in steps of two would suggest either you are starting off with an odd ammunition value, or you are reducing by 1 somewhere else.


#7

To add on to what the big old MrMen said. If you want to subtract 2 AND you’re at an odd amount of ammo, you will need to change > 0 to something like equal or greater then 2.

That way if you’re at 2+ ammo you can shoot, but if you’re only at 1 you can’t (which means you don’t get -1)


#8

I’ve alredy found how it had to work:


Also, they were to, so that’s why it did’nt worked:

thanks.