Does your cat really like being stroked or do they have a threshold before lashing out at you?
Maybe you notice that when you start to stroke them they start to swish their tails, the skin on their back ripples, ears flatten and start to act aggressively.
You might be interested to know that this could be a condition called hyperesthesia where by touch is overstimulating to them and can in fact cause some discomfort, for some owners it can seem like they are giving the cat an electrical impulse as the sensation overrides all normal behaviour.
Every cat is different and some may have a threshold in how much stroking they can tolerate, other cats may only tolerate touch on particular parts of their bodies such as the head. I have often seen cases where it is the movement of the hand stoking all the way down the back that causes most reactions. This behaviour is also very different to a cat or kitten that has not been exposed to being stoked or groomed as these cats often look like they might want to be stroked by rubbing up against you rather than being worried by you.
If your cat has signs of this condition or you find it difficult then I would be happy to help find some solutions to your kitty issues :-) x