My "Lava " script doesnt work

I want the player to teleport when touching lava. Here is my script i have applied to the lava
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Lava : MonoBehaviour
{

	public Transform player;
	public Transform spawn;
 	void OnTriggerStay ()
 	{
    		player.position = spawn.position;
 	}

}

If i use OnTriggerEnter it doesn’t do anything. If i have it at OnTriggerStay my character freezes in place and can’t move. I have isTrigger enabled.

I’m not that good of a coder so this might not work. but maybe using on Trigger enter would make more sense and use debug.log(“lava”) to see if the collision detection is the problem or
‘player.position = spawn.position’

This code should work.


   void OnTriggerEnter (Collider other)
          {
                if  (other.gameObject.tag == "Lava")
              { 
                    player.position = spawn.position;
              }
     }