Not sure if that’s the error you’re mentioning, but you should change if (FlxG.save.data.mainaNotesLoly > 12)
by if (FlxG.save.data.mainaNotesLoly >= Main.keyAmmo.length)
otherwise you’ll try to access data outside of your array.
12 is the last value but its index is 5.