Need help with my script.

I’ve been trying to add a pickup script for a game me and a couple others are working on, for some reason “inventory” isn’t recognised or something and gives me an error, any help would be appreciated, thank you. (PS: I’m very new to C# and scripting in general)

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

private Inventory inventory;

public class PickUp : MonoBehaviour {


    private void Start ()
    {
         inventory = GameObject.FindGameObjectWithTag("Player").GetComponent<Inventory>();

}

    // Update is called once per frame
    void OnTriggerEnter (Collider other)
    {
        if (other.CompareTag("Player")) {
            for (int i = 0; i < inventory.slots.Length; i++)
            {
                 if (inventory.isFull[i] == false)
        }
    }
}
}

4893569--473012--Script_1.PNG

Hi @Gillfish2102

“isn’t recognised or something and gives me an error”

Move your Inventory variable inside your class first and see if you still get other errors (now it is outside of your PickuUp class).

Ah , yes that fixed it, thanks for the response, didnt know it was that simple, thanks again.