The error refers to Line 25 but the actual problem might be earlier.
You script is greek to me, but perhaps it fails because it reaches the return statement. Something in you logic could be wrong, making it only work if has recieved a command recently. floodTest is related to command spamming, right?