That means the val[] array variable is of length = 0.
That means the val[] array variable is still null. That is, it has not been initialized yet.
So, why are those errors happening? Pay attention to this line of code below inside serialEvent():
Variable val[] is properly assigned w/ a float[] array only when serialEvent() is called back.
As you know, draw() is called back (much probably many times) much earlier before serialEvent() is called back for the 1st time!
However, you’re assuming that val[] is already an array of length = 2 at the lines below:
Given you expect to receive exactly 2 values from Serial::readString() each time it’s called back, you should pre-initialize val[] w/ an array of length = 2 (or more if you wish), so it doesn’t crash the sketch when draw() is called back for the 1st time:
float[] val = {}; → float[] val = new float[2];
P.S.: You don’t need redraw = true; when not using noLoop():