Collision Code help

Hello and thanks for your time! I designed a game and i have code that when trucks hit you that you will respawn at that starting point. And im have trouble with the code that when the trucks hit you and your NOT moving the trucks will go right through you, only when your moving and a car hits you will it respawn you at the spawn point. Ill post my code thats attached to the player as movement code and the truck collider. Thanks for your help! PS this is JavaScript

 This is attached to the moving truck

	gameObject.tag = "Truck";
	gameObject.tag = "Player";
     
    function OnControllerColliderHit(hit: ControllerColliderHit){
    if (hit.gameObject.tag == "Truck")
    {
		transform.position.y = 0;
		transform.position.x = 0;
    }
   
   }
 This Attached to the player

var character: CharacterController;
var speed: float = 5.0;   // moving speed
var direction: float = 1; // direction (-1 means -x)
var dead = false;

function Start(){
    character = transform.GetComponent(CharacterController);
}

function OnControllerColliderHit(hit :ControllerColliderHit)
{
	if(hit.gameObject.tag == "Truck")
	{
	dead=true;
	HealthControl.LIVES -= 1;
	}
}

function Update(){
	if (Input.GetKey (KeyCode.RightArrow))
	{
				print ("Right arrow key is held down");
    				character.Move(Vector3.right * speed * direction * Time.deltaTime);
    }	
    			
    else
   	{
    				character.Move(Vector3.right * 0 * 0 * Time.deltaTime);
    }
    
    	if (Input.GetKey (KeyCode.LeftArrow))
	{
				print ("Left arrow key is held down");
    				character.Move(Vector3.left * speed * direction * Time.deltaTime);
    }	
    			
    else
   	{
    				character.Move(Vector3.left * 0 * 0 * Time.deltaTime);
    }
    
    	if (Input.GetKey (KeyCode.UpArrow))
	{
				print ("Up arrow key is held down");
    				character.Move(Vector3.up * speed * direction * Time.deltaTime);
    }	
    			
    else
   	{
    				character.Move(Vector3.up * 0 * 0 * Time.deltaTime);
    }
    
    	if (Input.GetKey (KeyCode.DownArrow))
	{
				print ("Down arrow key is held down");
    				character.Move(Vector3.down * speed * direction * Time.deltaTime);
    }	
    			
    else
   	{
    				character.Move(Vector3.down * 0 * 0 * Time.deltaTime);
    }

}

I am not the best at this but in your truck script you might change the collider from tag “Truck” to tag “Player”, add a rigidbody to your truck and do the check for the collider in the player script check this link it has it all for you right there:

thank you ill try this