Instantiate prefabs by different types?

I feel this is very basic, but I just can’t figure it out.

In this video:

The script looks like this

using UnityEngine;
using System.Collections;

public class UsingInstantiate : MonoBehaviour
{
    public Rigidbody rocketPrefab;

    void Update()
    {
        if(Input.GetButtonDown("Fire1"))
        {
            Instantiate(rocketPrefab);
        }
    }
}

The “rocketPrefab” is initialized as a Rigidbody, but the prefab is a GameObject, maybe with a Rigidbody attached, isn’t it?

Why do this code not initialize “rocketPrefab” as a GameObject?

I am trying to do this:

using UnityEngine;
using System.Collections;

public class Spawn : MonoBehaviour {
   
    public GameObject prefab;
   
    void Start () {

        GameObject test = Instantiate (prefab) as GameObject;
        test.tag = "TagName";
    }
   
    // Update is called once per frame
    void Update () {

    }
}

The prefab is Instantiated, but I can’t set the tag name?

As mentioned, would it be nice to understand this. I feel I lack some basic understanding.

Thanks

u should check if u have the Tag named “TagName”

I have. The error I get is this:

“NullReferenceException: Object reference not set to an instance of an object”

if u have the prefab?it means the prefab is null;

But the prefab is Instantiated and live on my scene. Should “test” not be a direct reference to the GameObject?

I had to call it like this

test.gameObject.tag = “TagName”;