I do not think that script is written as plugin and thefore its dialog setting would not be recorded into an action step to bypass the dialog when the action is played. dlgMain is most likely a variable name user for the scripts dialog and for some reason it was not set.
That doesn't answer my question, I'm not an experienced script writer. How do I fix this?
If I was right and you tried recording using the script in an action. If that step does not contain recorded dialog setting you can see in the action step when you expand the action step. The script is not coded as a Plugin the script does not have action support coded in. To fix it you would need to add plug-in code required for action support.
Script that are Plug-in are usually listed in menu File>Automate>Name these can be recorded in actions they have code in them to record the setting used in their Dialog into the action step your recording. When the recorded action is played the scripts dialog will only be displayed and interactive if you turn on the steps dialog in the action. The Dialog setting are always retrieved from the Action step being played and set into place. If you did not turn on the action step dialog the dialog will not be displayed. If you turned on the dialog in the step the dialog will be displayed with the recorded setting in place. The step interactive requiring user intervention.