It is, just not of what you defined M as. Just add something like var/mob/living/carbon/human/U = M after the istype()