Enemy to Stop Pursuing Player if it Cannot Find Him After a Certain Amount of Time (C#)

(Keep in mind that this is in a 3D environment)

I have an enemy that uses a raycast to find where the player is. If the enemy finds the player, the enemy attacks and pursues the player. I want it so that if the enemy’s raycast does not pick up the player with a certain amount of time, the enemy will stop pursuing the player.

This is what I have so far. The actual attack behavior of the enemy is handled in a separate script at the moment

using UnityEngine;
using System.Collections;

public class LookAtPlayer : MonoBehaviour {

    private GameObject Player;
    private RaycastHit Hit;
    public bool SeesPlayer;
  
    void FixedUpdate ()
    {
        Player = GameObject.FindGameObjectWithTag("Player");
        var targetRotation = Quaternion.LookRotation (Player.transform.position - transform.position, Vector3.up);

        Vector3 RayDirection = transform.TransformDirection (Vector3.forward);
        Debug.DrawRay(transform.position, RayDirection, Color.green);
        if (Physics.Raycast (transform.position, RayDirection, out Hit))
        {
            if (Hit.transform == Player.transform)
            {
                Debug.Log("enemy sees player");
                SeesPlayer = true;
                if(Time.frameCount == 120 && Hit.transform != Player.transform)
                {
                    SeesPlayer = false;
                }
            }
            else if (Hit.transform != Player.transform)
            {
                Debug.Log("enemy can't see player");
                SeesPlayer = false;
            }
        }
        transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, Time.deltaTime * 100);
    }
}

Finding the player every frame is not a good idea for performance. Why not cache the reference ? Or assign it in the ditor. Also in your if statements you are comparing transforms why not compare game object references, which will be quicker and more reliable : Hit.transform.gameObject == Player.

As for your timeout, you need to start a countdown the first time your enemy cant see the player (when SeesPlayer goes from true to false) then every frame seesplayer continues to be false you need to countdown to zero. When you hit zero then you need to run your enemy gives up code. If during the countdown the player is seen again you need to stop the countdown (also reset the value to the max time).