Having trouble syncing players who join late

 void OnTriggerEnter2D(Collider2D collision)
    {
        if (gameObject.tag == "Player")
        {
            if (collision.gameObject.tag == "SpawnPointTeam1")
            {
                gameObject.tag = "PlayerTeam1";
                gameObject.GetComponent<SpriteRenderer>().color = Color.red;
            }
            else if (collision.gameObject.tag == "SpawnPointTeam2")
            {
                gameObject.tag = "PlayerTeam2";
                gameObject.GetComponent<SpriteRenderer>().color = Color.green;
            }
        }

The basic idea of this code, is that wherever the player is spawned will have a trigger which decides the team.
I have no idea how to sync this bit of code to late players who weren’t there when the color was changed from the default white.
The tag also doesn’t sync.
Can anyone help?

If the tags are correct on the host, you could run something on the host whenever a new player connects to reapply tags and color on either the single client who connected through a TargetRpc, or just to everyone with a regular client rpc. Doing the second would also correct the issue of the new player being white for all the existing players. I’m not sure it is the most efficient, but would probably work fine.

If tags aren’t correct on the host, then you could run a command to make the tags correct on the host whenever a player joins, then do as above.

You could use unity networking lobby which is available in the unity asset store. It waits until all players are ready. Otherwise you might want to make a script that makes all player wait until hosts hits start button.