What's wrong?

jremington:
This function is not correctly defined, and does not return a value:

BLYNK_WRITE(V4) // V4 is the number of Virtual Pin 

{
 int pinValue2 = param.asInt();
}

The Blynk library is kind of "unique". The BLYNK_WRITE() 'function' is really a rather complex macro. The 'parameter' ('V4' in this case) isn't actually used by the application code. You are correct that the return value from param.asInt() is thrown away as 'pinValue2' is a local variable. OP should use a global for this.