Your code prints both "Hey" and "Hey 2" because after you print "Hey", count is increased and also the second statement is true. For what you want to do you can try with something like this:
private String[] array = {"Hey", "Hey 2"};
private int count = 0;
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
if (!worldIn.isRemote()) {
playerIn.sendMessage(new StringTextComponent(array[count]));
count++;
return new ActionResult<>(ActionResultType.SUCCESS, playerIn.getHeldItem(handIn));
}
return new ActionResult<>(ActionResultType.SUCCESS, playerIn.getHeldItem(handIn));
}
If you want to make it loop between the Strings you can use an if statement to reset count.