In a Basic MSI project, I would not use a script. I would rather create a new Public Property through the property view. Call it MY_REG_PROP. Note public properties are written in all caps. Then, create a system search for the registry value you want to key from. If there is a value of the key it would be best. Tell the system search to just store the value in the property you created.
Lastly, I would create a new Custom Action of type error. I would schedule this action to occur in both the UI and Execute Sequence after app seach with the condition for both that your property contains the value you either do or don't expect. If the value is true, the error will pop, your message will be displayed, and the setup will abort. Note the error message is defined when you create the Error CA.
Make sure you have a default value for your public property.
Test your condition by making changes to the registry that app search is looking.