importing differing scripts

So, I’m developing a game, and I want each item to have a script for its behaviour when it is interacted with.

So I have a script on every item: (it gets run by a centralised “inventory” script)

 using UnityEngine;
 
 public class InventoryItem : MonoBehaviour {
        
     public Script useScript;

     public virtual void Use() {
     	// No script, bail!
        if (useScript == null)
            return;
        useScript.Use();
     }
 }

I want to be able to set “useScript” as a different script for each item; for example: a sword would swing, a bow would shoot, a spell would cast.

The type “Script” in the line “public Script useScript;” isn’t valid. I was wondering what I would do to import a script so I can set in the editor a different behaviour script on each gameObject the “InventoryItem” script is attached to?

I made a work around, where all the logic is in this script, but the inspector sets which to use.
using UnityEngine;

 public class InventoryItem : MonoBehaviour {

     [System.Serializable]
     public enum Type
     {
         None,
         Shoot,
         Swing
     }
     public Type weaponType;
     public int damage;    

     public virtual void Use() {
     	if (weaponType == Type.None) {return;}
        if (weaponType == Type.Shoot) {
            //run bow logic
        }
        if (weaponType == Type.None) {
            //run sword or axe logic
        }

     }
 }

If someone finds this in future and wants to use my code, there is no need to credit me as this script started out as something from a tutorial I can’t remember the name of. :slight_smile: