Photon Pun 2 assigning players' parent on each of their clients, but doesn't show together.

Hello, I have a 2-player multiplayer game where the players first select their character in the selection menu:
9034513--1247332--upload_2023-5-24_17-21-47.png

When they press start the game loads another level, but there is a DontDestroyOnLoad object called StatObject.
9034513--1247335--upload_2023-5-24_17-22-50.png
This Object contains the script below:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Photon.Pun;

public class StatObjectScript : MonoBehaviour
{
    public GameObject P1;
    public GameObject P2;

    bool spawned;

    bool found;

    [SerializeField]
    GameObject P1Spawn;

    [SerializeField]
    GameObject P2Spawn;

    public string P1GameObject;
    public string P2GameObject;

    GameObject waitForPlayers;

    // Start is called before the first frame update
    void Start()
    {
        DontDestroyOnLoad(gameObject);
    }

    void Update()
    {
        if(GameObject.Find("WaitForPlayers"))
        {
            return;
        }

        if (SceneManager.GetActiveScene().name == "FightArena" && spawned == false)
        {
            spawned = true;
            P1Spawn = GameObject.Find("P1Spawn");
            P2Spawn = GameObject.Find("P2Spawn");
            if (PhotonNetwork.LocalPlayer.ActorNumber == 1)
            {
                GameObject spawn1 = PhotonNetwork.Instantiate(P1.name, P1Spawn.transform.position, P1Spawn.transform.rotation);

                spawn1.transform.parent = P1Spawn.transform;

                P1GameObject = spawn1.name;
            }

            if (PhotonNetwork.LocalPlayer.ActorNumber == 2)
            {
                GameObject spawn2 = PhotonNetwork.Instantiate(P2.name, P2Spawn.transform.position, P2Spawn.transform.rotation);

                spawn2.transform.parent = P2Spawn.transform;

                P2GameObject = spawn2.name;
            }
        }


        if(spawned)
        {
            if(P1Spawn.GetComponentInChildren<PlayerScript>().dead)
            {
                StartCoroutine(WaitForTime());
            }

            if (P2Spawn.GetComponentInChildren<PlayerScript>().dead)
            {
                StartCoroutine(WaitForTime());
            }
        }
    }

    IEnumerator WaitForTime()
    {
        yield return new WaitForSeconds(4f);
        PhotonNetwork.LoadLevel("StartMenu");
    }
}

It's supposed to assign the players' parent to these gameobjects:
9034513--1247338--upload_2023-5-24_17-24-20.png
It does that but only on their own client, so P1 is assigned to P1Spawn on his client but P2 is not. How can I fix?

GameObject spawn2 = PhotonNetwork.Instantiate(...)

In this case, spawn2 is just a local object reference. The code you run on it won't be running on the remote machines and setting the parent is not synchronized automatically either. This means your parenting happens only on the client which is instantiating.
It might be better to reparent the client in a script that implements OnPhotonInstantiate. That would at least run on all instances (on the client that created the object initially but also all proxies).

See "Instantiation".