I did not check the rest of your code/ problem yet, but change while(!my.client_id) wait(1); to while(my.client_id < 0) wait(1); That's what you should do with every dynamically created entity (if you create them on the server, it won't matter, of course).
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual