ID:169256
 
if(M.type == /mob/townsperson)


That includes everything inside "townsperson", like /mob/townsperson/bob and /mob/townsperson/george, right? I forget all the easy things =P
Try if(istype(M, /mob/townsperson)). istype() includes the type you give it as well as any subtypes.
In response to Jon88
That's right

that really was quick =P