Am I doing this right?

So im trying to use a script for an enemy to attack. However the enemy falls through the floor. I there a problem with the script so far or is it the actual enemy entity?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AttackPlayer : MonoBehaviour {

private Transform player;

// Use this for initialization
void Start ()
{
    player = GameObject.Find("Player").GetComponent<Transform>();
}

// Update is called once per frame
void Update ()
{
    transform.LookAt(player);
    transform.position = Vector3.MoveTowards(transform.position, player.position, 2*Time.deltaTime);
}

void OnTriggerEnter(Collider other)
{
    if(other.GetComponent<Collider>().name == "Player")
    {
        Application.LoadLevel(0);
    }
}

}

If the enimy if falling through the floor, you need to add a new collider to the enimy and paste in the same values as before, but turn is “is trigger”. It’s very important you do this. If you only have one collider that’s a trigger, it’s not going to do what you want it to. You however do need a trigger collider for this to work.

Also you should make a
[SerializeField]
Before the private Transform so that you can see it in the inspector, and assign it manually once. Using GameObject.Find() is SUPER slow and inefficient.