Display text when ray hits and object

Hello!
I am making a solar system exploration project and I am very new to the Unity. I am stuck at a point where I want to display the information about the planet as soon as my ray interactor hits the planet. The text should also disappear when my ray interactor is not pointing at the planet.
I tried many things, but nothing has worked out till now.
Any help/suggestions?

Thanks!

Hey !
Can you show us some code to help you with ?
Also I would like to suggest you to set a tag to the planet so when you do your ray, you can check if it hits something by the id you got and after that you should be able to call the function that will set the visibility of the text.