Need help with my gun shooting script!

Hello everyone, I hope you are having a good day! I am new to C# and Unity in of it’s self, and I am slowly learning C#, but I found a video on youtube from Brackeys on how to shoot with Raycasts. I think I followed the script, but I get the error “The type or namespace name ‘Target’ could not be found (are you missing a using directive or an assembly reference?)”. Here is the code and help would be most appreciated!:

using UnityEngine;

public class Gun : MonoBehaviour
{

    public float damage = 10f;
    public float range = 100f;

    public Camera fpsCam;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            Shoot();

        }

    }

    void Shoot ()
    {
        RaycastHit hit;
        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range));
        {
            Debug.Log(hit.transform.name);

          Target target = hit.transform.GetComponent<Target>();
            if (target != null)
            {
                target.TakeDamage(damage);
            }
        }
    }
}

The error tells you that the compiler does not know what “Target” is. Do you have a Target script?

Also, not necessary here, but in the future i’d advice to post the full error message including the line^^

Awesome, thanks! I think it might be because I named my enemy “enemy” and not target, let me see if that is the problem…

okay, I fixed, thank you for your help, and have a wonderful day!