Enabling/Disabling input using linetrace Noob HELP

First of all I’m a newbie,. So I’m sorry if my question is pretty dumb :rolleyes: :wink:

I just hope you can help me with this one.

How can I enable input when a ray hits an object(in my case a lamp) so if I press “F” I can turn the light ON/OFF and disable the input when the ray is not hitting the object so if I’m away and I press “F” I cant turn the lights ON/OFF.

with a helpful message that says “press F” when the ray hits that certain object.

ok so heres my graphs.
INTERFACE
6c3251fcf8302e468d3aac04d21695aba6919bbb.jpeg

FIRSTPERSON LINE TRACE
f5480fea969982b24421c4fefb090415c0124bbe.jpeg

and heres where I’m having some problem,. so I can enable input but I dont know how to disable it when the ray is not hitting the object. So once the ray hits the object, it stays enable all the time and I can toggle the light even if I’m away.

if I can just disable it when the ray is not hitting the object.