Patience!
Your Riolu needs to have at least 220 Happiness to evolve. Once this number is reached, you must level it up during day time. If you're playing Moon, maybe the inverted day/night is causing an issue, so you might want to switch things up.
Apart from that, you can try the following:
- Giving Riolu a Vitamin (Protein, Carbos, etc)
- Giving Riolu a Massage (available once a day) in Konikoni City
Aside from that, any EV wings you might have also give a small boost, and as usual, walking around without fainting with a Soothe Bell is a slow but steady way of boosting happiness. Use Riolu in battles against important trainers (Island Kahuna, Champion, etc).
Source: Bulbapedia
PS: Keep in mind that you need to be patient, and continue walking around without letting it faint.