Treat Instantiated Objects as GameObjects

So I’m trying to make a multiplayer game where you can die and after you respawn based on the amount of lives you have you can choose to either respawn or wait until the next round.

I’m controlling each player with individual character controllers that instantiate in for each player. The issue I’m having is assigning the repsawned character after instantiated. Basically the character will work but all attached functions with the respawn scripts can’t be accessed because I can’t reassign the new player object to a GameObject variable.

Here’s my code:

void Respawn(bool info)
    {
        if (info == true)
        {
            var respawned = Instantiate(characterPrefab, spawnLocation, transform.rotation);
            characterObj.gameObject = respawned;
            respawnButton.SetActive(false);
        }
    }

The characterObj variable is the GameObject assigned character in game
The characterPrefab variable is the prefab I want to respawn

Any ideas?

What’s the type of characterObj?

Try characterObj = respawned;