Finally I got it to work, thanks a lot everyone for helping me out. The main problem (type undefined is not an int) was already fixed by Tally in an earlier post, but the same error came because of the bots (I forgot that their guid is always 0 ), so i made the script compatible for bots also, and now there ain't any problems no more, big thanks to you guys again!