He says hi when my friends are not with me?

This guy only talks to me when my friends are not around me I’m confused like today in class my friend went to ask something to the teacher and he was with his friends and he turned around and said hi to me it’s always when I’m not with my friends