How to make a MatchTimer in unity photon Pun

Hello I am searching for days on how to make match timer that when that time finishes the match ends.
Now I am using this code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using TMPro;
using Photon.Realtime;
public class Timer : MonoBehaviourPunCallbacks
{
    bool startTimer = false;
    double timerIncrementValue;
    double startTime;
    public static double timer;
    ExitGames.Client.Photon.Hashtable CustomeValue;
    public GameObject scoreBoard, scoreManager;
    public TMP_Text timerUI;
    void Start()
    {
        
        if (PhotonNetwork.LocalPlayer.IsMasterClient)
        {
            CustomeValue = new ExitGames.Client.Photon.Hashtable();
            startTime = PhotonNetwork.Time;
            CustomeValue.Add("StartTime", startTime);
            PhotonNetwork.CurrentRoom.SetCustomProperties(CustomeValue);
            startTimer = true;
            Debug.Log("Going to send to client");

        } else
        {
            SendToClient();

        }

    }
    void SendToClient()
    {   
            Debug.Log("Checkign If we are not");
            startTime = double.Parse(PhotonNetwork.CurrentRoom.CustomProperties["StartTime"].ToString());
            Debug.Log(startTime + " Client Time");
            startTimer = true;
      
      
    }
    void Update()
    {
        if (!startTimer) return;
        timerIncrementValue = PhotonNetwork.Time - startTime;
        timerUI.text = timerIncrementValue.ToString();
        if (timerIncrementValue >= timer)
        {
            if(PhotonNetwork.LocalPlayer.IsMasterClient)
            {
                photonView.RPC("endGame", RpcTarget.All);

            }
        }
    }
    [PunRPC]
    void endGame()
    {
        EndGame();
    }


    public void EndGame()
    {
        //PlayerMulti.playerMulti.Allcanvas.SetActive(false);
        scoreBoard.SetActive(true);
        scoreManager.SetActive(true);


    }
}

It always showed me there is a problem at this line of code
startTime = double.Parse(PhotonNetwork.CurrentRoom.CustomProperties["StartTime"].ToString());
I really dont know what to do and I cant find a solution for it.
Thank You

You will have a lot of issues with your current code.

First up: Never call an RPC from the Update

This is reeeallly important as it unecessarily spams information while you only can send 500 msgs/room/second.

Then to your main issue:
Please always add error information “if there is a problem with a line” as you described it. The error message gives the direction for a solution in 99.9% of cases.

Other then that: I’d stongly suggest you send the start time using a buffered RPC. Do not use a Custom property here unless you really want to make this a value that can be used for “matchmaking”.

In addition to that i assume that your start code is not correct as the masterClient will set it’s start time but will not send it to other players at the moment.
Instead everyone else will call SendToClient once they join the scene.

         if (PhotonNetwork.LocalPlayer.IsMasterClient)
         {
             CustomeValue = new ExitGames.Client.Photon.Hashtable();
             startTime = PhotonNetwork.Time;
             CustomeValue.Add("StartTime", startTime);
             PhotonNetwork.CurrentRoom.SetCustomProperties(CustomeValue);
             startTimer = true;
             Debug.Log("Going to send to client");
             //this is what i'd suggest you to do: (assuming the transform of this object has a PhotonView)
             //photonView.RPC("StartTimeSync", RpcTarget.AllBuffered, startTime);
             //this is what you currently do:
             SendToClient();
         }

Follow this youtube tutorial…