Instantiate prefab issue using string name

Hi, I have an Array for 2 players. I am adding a list of string names to the array as a player clicks on items. When the player closes the window I am trying to Instantiate items to the game but I am getting an errors.

And this error

I’m pretty sure I understand the errors, the Instantiate() method is looking for the prefab for it’s first argument and I am passing it a string that has the name of the prefab I want it to Instantiate.

Here is the code so far, it is still a work in progress, but I am looking for a way to store the names and then instantiate the Prefabs based on the name of string names in the array?

    public void purchaseItemButton(string name){ // When button is pushed, pass the name of the prefab you want
        float cameraPos = Camera.main.transform.position.x;
        bool isRight = (cameraPos > 0) ? true : false;

        if(isRight){
            if(playerRArray.Length < 5){
                playerRArray[playerRArray.Length] = name; // add the purchased name of item to the player array
            }
            else{
                print("To many items");
            }
        }
        else{
           
        }
    }

    public void buyingStoreHideShow(bool state){
        float cameraPos = Camera.main.transform.position.x; // Check which side the camera is on to determin the player.
        bool isRight = (cameraPos > 0) ? true : false;

        if(isRight){
            for(int i = 0; i < playerRArray.Length; i++){
                Button but = Instantiate(playerRArray[i],Vector3.zero,Quaternion.identity);
            }
        }
        GameObject sm = GameObject.Find("Canvas/Store");
        int count = sm.transform.childCount;
        for(int i = 0; i < count; i++){
            sm.transform.GetChild(i).gameObject.SetActive(state);
        }

        bool tempState = (state == true) ? false : true;

        WindSpeedGraphics(tempState);
        PlayerRHide_Show(tempState); // hide user standard graphics when looking at the Store
    }

Why not just store the prefab in your list/array instead of strings?

That was the general idea, but I am at a loss as how to do that. The user pushes a UI Button and then in the Button Component there is the “On Click” That is where I send the string to the code, am I able to send a prebab that way?

Thanks, I have some code working now. I changed the code in the method to except a GameObject instead of a string and then dragged the prefab to the “On Click” and it is instantiating the prefab now. The button image is blank but I am working in the right direction now, thanks!

Glad you got it working. Good luck!