Unfortunately I'm not a scripting expert, but I know we have a few members here who are. Maybe something would stand out to one of them if they see this discussion and notice something wrong with your code.
In the meantime; you mention there's an error, but no description of the actual error message itself? Perhaps if you shared that, this might point to something else outside of the coding that needs to be addressed.
CG - GoDaddy | Community Moderator 24/7 support available at x.co/247support