Don't know if it helps, but when going over the script I found a few more possible problems + I thought it was a bit slow, so I made it faster.
If that does not help, where do you see the errors? If you also see the errors, when you only start the game (not my script), then something in there is going wrong and I can't change that. Sorry.