Unity giving out of range exception only on build

I have this really random problem, in the editor the game works without a single problem, but on the build it gives and index out of range exception, so I added an if check to see if the number was out of range and if it was gave a default value, but still the problem persists.

index out of range is propably due to your array. have you instantiated it?
or you are trying to access something outside your array.

what you could do is to make an array bigger than you need and see if that helps, if it does you are trying to access outside of the array.