I had a quick look at the code, and theres a lot of stuff you use that I've never learned about, so I don't know what most of your functions are trying to do. However, I found whats wrong with the score and made a solution. Firstly, the variable "score" isn't defined. Secondly, when you say:
var...