I have found the bug!, it's when you press the mouse button to fast, with your system you keep adding a value to the cooldown. So the solution is to set a max value to the cooldown
The cooldown was basically to wait until all bullets (rocks) are gone and then you could move but it was glitcy when spammed, did it so you have half a second of cooldown before next shot... hope that solves the problem