Make sure that you sound sincere. If said in the wrong tone, this phrase can be interpreted as sarcasm. So make sure that the person understands your sincerity when you express the sentiment.
Some people dislike the phrase because, they feel, it carries a note of negativity. “Good luck” for them implies that you have little to do with your own success.[1] Use the phrase at your discretion