referencing one script in another

I know its probably an easy fix, but I am having trouble referencing variables from script “FirstPersonController” in script “UserVitalStats”
This is what I have:

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

public class UserVitalStats : MonoBehaviour
{

    CharacterController charController; //works
    FirstPersonController playerController; //doesn't work--error


    void Start()
    {
        userHealthSlider.maxValue = userMaxHealth;
        userHealthSlider.value = userMaxHealth;
        userHealthRegen = 0.5f; //may change later?
        userEnduranceSlider.maxValue = userMaxEndurance;
        userEnduranceSlider.value = userMaxEndurance;
        userEnduranceSlider.maxValue = userMaxEndurance;
        userEnduranceSlider.value = userMaxEndurance;
        userEnduranceDegen = 1;
        userEnduranceRegen = 1;
        userCurrentHunger = userMaxHunger;
        userCurrentHydration = userMaxHydration;
        userCurrentSleep = userMaxSleep;
        userCurrentHygiene = userMaxHygiene;
        userCurrentTemp = userNormalTemp;


        charController = GetComponent<CharacterController>();
        playerController = GetComponent<FirstPersonController>(); //doesn't work--error
    }

This ^^ was where I am trying to call in the script.

Below is the script variables I am trying to reference:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FirstPersonController : MonoBehaviour
{
    //player movement
    [SerializeField] public float moveSpeed = 4.0f;
    [SerializeField] public float runSpeed = 8.0f;
    [SerializeField] public float runSpeedNull;
    [SerializeField] public float rotateSpeed = 100.0f;
    [SerializeField] public float jumpForce = 500f;
    [SerializeField] public float gravity;
    public bool canMoveSideways = true;

    public bool isWalking;
    public bool isRunning;
//the rest is irrelevant
}

I followed a tutorial to the T (I checked multiple times) and am wondering if the specific tutorial led me in the wrong direction. Other tutorials wouldn’t match well with what I was trying to accomplish.

What is the error message?

It depends on how you have your game object setup. Is FirstPersonController on the same object as UserVitalStats, or is one on a child object of the other? GetComponent only gets components that are on the same object. You may need one of the related methods GetComponentInParent or GetComponentInChildren.

The error that I am getting is:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name ‘FirstPersonController’ could not be found (are you missing a using directive or an assembly reference?) Assembly-CSharp C:\Users\Alyssa\Desktop\Cryptic\Unity\Cryptic from Tutorials (maybe use later)\Assets\Scripts\UserVitalStats.cs 115 Active"

Also, they are on the same game object: (image attached)

It may be cliche, but have you tried restarting Unity and VS? If so, the next thing I’d check is where those two scripts are located in your project. Is one accidentally in an editor folder? Are there assembly definition files that need to be configured?

Well, error message clearly states the problem. Assembly references are managed by Unity, but using directives you should add yourself.

They are both in my “Scripts” folder.

I am fairly new at this, so what using statement should I be inserting then?

For instance–I tried using namespace.FirstPersonController
but received the error that it is a namespace but is used like a type

Nah, doesn’t look like their FPC is in a namespace.

The next thing you can try is to right click on each script in the project folder and select Reimport. If that still doesn’t work, you can close Unity, open a file browser and navigate to your project, and then delete the Library folder (should be next to the Assets folder, not inside it). That is safe to do and will cause Unity to rebuild its references. That will cause the first time reopening the project to take a while.

YES!!! Thank you so much! I’ve been going over the same code and researching this for the past two days and I just could not find where I went wrong–and it was as simple as reimporting. I won’t forget this now. Thanks again!