Hi.
Maybe set the "selected" object on a "selected" variable.
when you do raycast again and hit something, compare it to the "selected" variable.
If same do nothing, if not same reactivate the selected "selected" and then update the "selected" variable with the newly selected (this can also be null)
if null, skill setting selected.
if not null set that one highlighted