Problems in continuous fire

When I hold down the fire key, I can continue to shoot even if the number of bullets is zero.

How should I revise it?

in your example the value of the loop pin will not change unless you press the button again. this means that the check for amount of ammo is not being done which is due to using a timer here. theres two ways to solve this:

first you could add a check after the start fire event which checks the ammo level and if theres no ammo then you clear the timer, in this case you would just have the timer set to always loop. see picture capture1.

the second method would be to rebuilt the script entirely and eliminate the timer, instead opting to make your own loop. see picture capture.

That’s because your logic is wrong. You are only checking ammo before you set the timer. Once the timer is set it keeps calling ShootFire without checking ammo.

simply check ammo on start fire before calling shoot fire…

Wops, looks like Thompson beat me to it with a more details and better solution

Thank you. Your answer is very useful for me.

Thank you. I learned a lot of new knowledge.

You are welcome, I’m glad I could help!