I think the problem is that you are just trying to copy+paste my code snippets directly into your script and expecting it to work

For the most part, the code I type in here should be considered at best "pseudo code" and at worst, totally broken

The error is most likely caused by "numbets" not actually being a declared variable. I think the inbuilt variable is actually called "bets", but I was trying to illustrate what the variable was actually representing...
Ok, that's absolutely fine! I'll try to deep digger on it and with the variables. I'm very rookie with this, i never made or used or understand a single piece of code until i found this program, so i'm basically learning from scratch. anyway thanks!