Player prefab instantiation

Hello,

I want to instantiate a different game object for each player, so I made 2 prefabs in the resources folder (redPlayer & bluePlayer).
In my GameManager, I declared two public gameObjects, RedPlayer and BluePlayer and assigned the prefabs from the resources folder to those GameObject on the script.

An I have made another GameObject for the player prefab. here is the code

if (PlayerManager.LocalPlayerInstance == null)
                {
                    
                    if (GameObject.Find("redPlayer"))
                    {
                        playerPrefab = BluePlayer;
                        PhotonNetwork.Instantiate(this.playerPrefab.name, new Vector3(0f, 5f, 0f), Quaternion.identity, 0);
                    }
                    else
                    {
                        playerPrefab = RedPlayer;
                        
                        PhotonNetwork.Instantiate(this.playerPrefab.name, new Vector3(0f, 5f, 0f), Quaternion.identity, 0);
                    }
                }

However, when playing, I get an error message that the playerPrefab wasn’t assigned.

Im not sure but it seems like your code doesn’t handle a situation where both the blue and the red players can not be found. Because if red is found then blue is instantiated. The else says if red can’t be found then instantiate red. But what if both both object cant be found? with this code only red would instantiate. Unless, you have another script to call the logic twice. Like i said im not sure, don’t attack me if im wrong lol.,I’m not sure but it seems like your saying if the red player is defined then instantiate the blue player.
then with the else your saying if the red player is not defined instantiate the red player. Are you sure you didn’t get your logic in reverse? if you didn’t it might work if you check for blueplayer and do what you did for your redplayer in the second if statement. My point is what if the blueplayer is defined your code should work. But your code doesn’t handle the variant where both player objects can not be found.