i used a timer and when it’s off, it’s supposed to completely stop the laserbeam from appearing at all, but when the timer is false, it lets it play once and then not again. I don’t know what I did wrong, and can’t find anything that stands out in the code
I’m guessing that when you want to start the laser again, you set the beamtimer = true?
You are not checking anywhere for the value of beamtimer except for in the _ready() and right after the attack() is finished, so when you switch the value to true, it doesn’t do anything anymore.
You should call attack_delay() instead.
However, this whole setup could be improved if you get rid of all awaits and use proper signal handling instead.
So you don´t want the laser beam to appear at all when beamtimer is false, but it does appear once. Am I understanding the problem correctly? If so, then the issue is that something external to your function is calling attack or attack_delay. So simply don’t do that then.
More serious problem: you have infinite recursion between attack and attack_delay, which will eventually blow your stack. I suggest a non-recursive rewrite. Something like this: