Why does unity crash when i use this code.

I have been trying to fix this problem for hours and the only sulotion I can come up with makes unity crash.

Crashes:

if(weapons[x+1].unlocked)
		currGun = x;

That’s a pretty peculiar-looking for statement. I can’t quite follow the logic of what you’re trying to do, but it seems you’re creating an infinite loop.

 for(int x = currGun+1; x != currGun; x++) {

So, x starts as one greater than currGun, but then rises until it’s equal to currGun?
The only way that could happen is if weapons[x+1].unlocked = true, which obviously never happens, so the loop never breaks.