The error "Script output values are not defined or improperly defined.“ is likely a result of not generating the script output for the component monitor (clicking "Get Script output". So while the script may look fine, and probably works correctly, SAM doesn't know the names of the output values and returning that error.