How to Stop Timer when User Collides with Object

Hello everyone,

I have set a timer, it is working great but i cannot let it stop when user collides with another object.

Text text; float theTime;

public bool timer;
void Start()
{
     text = GetComponent<Text>();
}
void Update()
{
     if (timer == true)
     {
         theTime += Time.deltaTime;
         string seconds = (theTime % 60).ToString("0");
         text.text = seconds;
     }
}
}

How may I give reference to another script to call these methods when user OnColliderEnter2D method ?

I have tried calling reference methods on internet but did not work.

Thank you very much for your help.

Why not use a Scriptable Object? Have it reference the float variable.
A Monobehaviour script that updates the value. Another Monobehaviour that updates the UI using the data from the scriptable object. A nice way of splitting updating the value and updating the UI, then when you test the value updater it doesn’t require the UI. The other way around as well the UI doesn’t need the updater as it is getting its values from the scriptable object.
once the player enters the collider get the component that updates the value and just disable it using enabled = false;