How can I set parameter of player clone ?

Hi. I made a transfer code, if player clone touched the door, player will transfer to another room. But it doesn’t work. I think ‘currentMapName’ is only set in player object, not clone object. So I want to know how can I set parameter of clone object. Thanks for anything your helps.

the error code


transfom source code

    public string  transferMapName; // map name for transform

    private PlayerScript thePlayer;

    // Start is called before the first frame update
    void Start()
        thePlayer = FindObjectOfType<PlayerScript>(); // player objects.

    private void OnTriggerEnter2D(Collider2D collision)
        if ( == "Player(Clone)")
            Debug.Log("Hit door");
            thePlayer.currentMapName = transferMapName;

and clone parameter that I want set value


Does your Player(Clone) have the player script on also?

Do you instantiate the Player(Clone)? If so you can transfer Players “CurrentMap Name” to the cloned players PlayerScript at the point of instantiation.

Alternatively, it looks like the script hasn’t found the “thePlayer”, try using

        thePlayer = GameObject.Find("Player").GetComponent<PlayerScript>();

In place of FindObjectOfType