Turning off script in prefab does not affect the clone of that same prefab

To say the question very compactly:

public Vector3 playerSpawnValues;
public GameObject player;

void Awake() {

    Vector3 playerSpawnPosition = new Vector3(playerSpawnValues.x, playerSpawnValues.y, playerSpawnValues.z);
    Quaternion playerSpawnRotation = Quaternion.identity;
    Instantiate(player, playerSpawnPosition, playerSpawnRotation); //works to here.
    player.GetComponent<PlayerController>().enabled = false;
    player.GetComponent<AlternativePlayerController>().enabled = false;
   if (player == null)
    {
        Debug.Log("player er null");
    }
    else
    {
        Debug.Log("player er ikke null");//works

}

This code only turns off the two scripts on the prefab not the clone that I actually use in the game which means it has no effect since it is the clone that is actually used. Why and how do I fix it so the clone is affected by turning off the script and not only the prefab, can someone please tell me that.

And one last thing if I select the prefab while running the game and deselect the two scripts nothing happens, if I do the same with the clone I get a response.

Hello.

Its simple: You need to declare the clone to be instantiated so you can modify it:

 GameObject NewClone = Instantiate(player, playerSpawnPosition, playerSpawnRotation); //works to here.
 NewClone .GetComponent<PlayerController>().enabled = false;
 NewClone .GetComponent<AlternativePlayerController>().enabled = false;

Bye! :smiley: