Opening/Closing door using raycast script dont work...help me

Hi, i try to find the answers on unity and youtube but i cant find why my script wont work. I dont get an error but my script just do nothing.I want my player(first person) to open door when he look at it. I put the script on the camera.The debug.ray show exactly the ray i want. Here the script:

function Update () 

{

var Hit:RaycastHit;

if(Input.GetKeyDown(KeyCode.T) && Physics.Raycast
(transform.position,transform.forward,Hit,5))

{

if(Hit.collider.gameObject.tag=="porte")

{

Debug.Log("La porte Ouvre");

}

}

Debug.DrawRay(transform.position,transform.forward*5,Color.green);                                                                                                                                                                                                                                                                          
}

I dont know why i wont work i check the tag i use a built-in one like Player nothing seems to work if someone could explain me why it will be great cause it will be usefull to me to understand raycast.

Hi Samueld28,

Your issue may reside in your variable naming of “Hit”. I have renamed your variable to be lowercase “hit” which should not cause an issue.

Try the following and let me know how you go.

function Update () 
 
{
 
var hit:RaycastHit;
 
if(Input.GetKeyDown(KeyCode.T) && Physics.Raycast
(transform.position,transform.forward,hit,5))
 
{
 
if(hit.collider.gameObject.tag=="porte")
 
{
 
Debug.Log("La porte Ouvre");
 
}
 
}
 
Debug.DrawRay(transform.position,transform.forward*5,Color.green);                                                                                                                                                                                                                                                                          
}