Instantiate() wont work

I am trying to duplicate a player menu in this chunk of code

        GameObject MakeSpecificMenu = Instantiate(playerMenu);
        RectTransform MSMrt = MakeSpecificMenu.GetComponent<RectTransform>();
        MakeSpecificMenu.transform.SetParent(playerMenu.transform.parent);
        MakeSpecificMenu.name = tempPlayer.Name + " menu";
        Debug.Log(MakeSpecificMenu.name);
        MSMrt.anchoredPosition = new Vector2(500, 50);
        MSMrt.localScale = new Vector3(1, 1, 1);

This is the log:


The errors appear after I try to open it because it can’t be found and that it because for some reason it doesn’t exist.

I assume you did not set playerMenu in your inspector

I have set it

Let’s not argue (again) about null references.

If you think you set it, you didn’t.

If you DID set it, then something ELSE is null.

It’s not a matter of debate, it’s not a matter of disagreement.

Go fix it. Start at Step #1. Do NOT start at any other step. Here’s how:

The answer is always the same… ALWAYS!

How to fix a NullReferenceException error

https://forum.unity.com/threads/how-to-fix-a-nullreferenceexception-error.1230297/

Three steps to success:

  • Identify what is null ← any other action taken before this step is WASTED TIME
  • Identify why it is null
  • Fix that

fixed it I got confused with the names

I set the name to the wrong object because I copy-pasted it and forgot to switch variables this is in a part I didn’t attach so there was no way you could help me with that
but thank u both for trying