I added an invisible wall that when the bullets touch it, they dissapear. The glitch was because when you go to the bottom or top, the bullets from the enemy would instantly touch the edge and die out.