I am making a top-down shooter also I am new to coding so I will make mistakes but how do I loop this if statement because every time I shoot I loose 1 ammo and I have 6 bullets
and if I use all 6 the if statement gets triggered but it only triggers once then doesn't work anymore. Sorry I am bad at typing
if Input.isactionpressed("uifire") and canfire:
var bulletinstance = bullet.instance()
bulletinstance.position = $BulletPoint.getglobalposition()
bulletinstance.rotationdegrees = rotationdegrees
bulletinstance.applyimpulse(Vector2(), Vector2(bulletspeed, 0).rotated(rotation))
gettree().getroot().addchild(bulletinstance)
ammo -= 1
print("Taking 1% ammo")
canfire = false
yield(gettree().createtimer(firerate), "timeout")
can_fire = true
**if ammo == 0: ***#This entire if code is my problem***
**print("Notice 0% ammo")
reload = true
can_fire = false
yield(get_tree().create_timer(reload_speed), "timeout")
print("Finished Reload")
can_fire = true****