It has obscure meanings, and we should relate the sentence with specific occasion to understand it.
For example, in this sentence: "我只和他打篮球, 我不和别人打篮球". It can be translated into "I play basketball only with him, but no one else".
But in another example: "我只和他打篮球, 我不和他打羽毛球". It can be understood as: I only play basketball with him, and I don't play badminton with him.
Besides, How we segment and stress the the words, or punctuation can also influence our understanding of the sentence. If we stress on 他, which is 我只和(他) 打篮球, then it is "I play basketball only with HIM". and if we stress on 打篮球, then it is "I only PLAY BASKETBALL with him"