I am working on a game, but there is a problem that when the player holds down the attack button, he continuously attacks until you release the button. What script do you use to make it so they only attack once when you hold it down?
I actually found a better way, because the players are supposed to spam the button, but not hold it down. if(Key.isDown(Key.SPACE)){ if(AttackVar == false){ this.gotoAndStop(3); attack = true; AttackVar = true; } attackButton = true; }else{ attackButton = false; } if(attackButton = false && attack = false){ AttackVar = false; }
But I think I have an unnecessary amount of variables. The script works though.