Hamill’s Luke Skywalker, who sacrificed himself at the end of Star Wars: The Last Jedi, managed to make a brief (but important) final appearance in The Rise of Skywalker. Now a Force spirit, he encourages Rey not to give up on the Jedi, giving her the extra push to face her grandfather, Emperor Palpatine.
Article source: https://www.cinemablend.com/news/2493903/mark-hamill-thanks-star-wars-fans-with-heartfelt-letter-at-the-end-of-an-era