First thing off the bat, you're using legacy objects with the new imports, "closestObjectForName" is now "objects.closest()"
Heres the api: http://osbot.org/api familiarize yourself with it, you also need to Override the onLoop().
Looks like you've taken an OSBot 1 script, changed the imports from legacy, it doesn't work like that unfortunately.