# Instantiate player prefab using player data

When my scene loads, I want to add my prefab to it along with its components.

Here is what I mean:

2. player gender is determined via playerprefs or playfab sdk
3. player prefab is loaded and displayed using said gender

The prefab would have a script components attached for the current data etc.

I might be approaching this wrong, but I want this to work with multiplayer in the future, so that's why I didn't just add the prefab directly to the hierarchy.

What is the correct way of doing this?

• Welcome to GDSE - what have you tried so far, and where are you getting stuck with it? Is your specific problem about instantiating prefabs, modifying them after instantiation, or something else?
– Joe
Aug 12 '19 at 19:55

Can you use DontDestroyOnLoad for your player ? Maybe you could use an external script that assign what you want in your player script depending of what you want. Ex:

GameObject player;

void Start()
{
player = GameObject.Find("player");
if(//insert condition)
{
player.GetComponent<playerManager>().gender = "man";
}
}

• This answer would be better if it included a step-by-step breakdown or example code demonstrating how this strategy could be applied to solve OP's problem. Aug 12 '19 at 20:11