Are you using any other scripts in your project?
Just because it flags up the error in a particular script doesn't always mean it's that script that is causing the issue. Often, with a nil:NilClass error it's a compatibility issue with another script. If there are other scripts, what you can do is remove all the scripts and add them back one at a time.
An easy way to do this is to Cut and Paste the Main script and put it above all your custom scripts, then move it down through each one, testing as you go. When you hit this problem then, play around with the ordering of the scripts you have by moving the last script up a level each time and testing again. If the problem gets fixed, move the Main script back to the bottom and test again. All being well, the issue would be solved. If another comes up, do this again from where you left off.