System Events got an error
I tried downgrading to the last itunes version that was supported but still no luck. Would me being on sierra have anything to do with it? Any advice would be greatly appreciated.

The version of iTunes isn't the only thing that breaks this script. iTunes seems to load html content from Apple servers for the account creation pages and that content changes even for older iTunes versions. I gave up trying to fix or use this script this year as I Apple seems to now require verifying the email address during account creation and, in addition, there was a captcha. We made about 100 Apple IDs by hand instead. I would have used Managed Apple ID if a Managed AID could redeem a gift/VPP codes for books, but that doesn't work. My hope is Apple will change that by next summer.