Destroying platforms

Hello everyone! I have a problem with my Destroy Platform scripts. Here’s the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DestroyPlatform : MonoBehaviour {
    public int timeToDestroy;
    public int timeToRespawn;
    Collider2D platformColider;

	// Use this for initialization
	void Start () {
        platformColider = GetComponent<Collider2D>();
	}
	
	// Update is called once per frame
	void Update () {
        if (timeToDestroy < 50)
        {
            timeToDestroy = timeToDestroy - 1;
        }
        if (timeToDestroy == 0)
        {
            platformColider.enabled = false;
            GetComponent<Renderer>().enabled = false;
            timeToRespawn = -40;
            timeToDestroy = 50;
        }
        if (timeToRespawn < 0)
        {
            timeToRespawn = timeToRespawn + 1;
        }
        if (timeToRespawn == 0)
        {
            platformColider.enabled = true;
            GetComponent<Renderer>().enabled = true;
            timeToDestroy = 50;
            timeToRespawn = -40;
        }
	}
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag == "Player")
        {
            timeToDestroy = 49;
        }
    }
}

So basically what I wanted to is: when Player jumps on platform it should disappear after the certain amunt of time (which it did) and then appear again (which it did too), but after that it wouldn’t reset the timer, which is set in this part:

    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag == "Player")
        {
            timeToDestroy = 49;
        }
    }

it worked only 1 time when Player jumps on the platform for the first time and then it didn’t reset the timer again.

hi,you better to use a coroutine instead of update function.

  public bool playerjumpedOnPlatform;

private void OnCollisionEnter2D(Collision2D other)
{
	if (other.gameObject.tag == "Player" && playerjumpedOnPlatform==false)
	{
		StartCoroutine ("waitTodisappear");
		playerjumpedOnPlatform = true;
		 
	}
}

public IEnumerator waitTodisappear(){
	yield return new WaitForSeconds(50);//after 50 secs  it will deactive the platform....
	GetComponent<SpriteRenderer> ().enabled=false;
	GetComponent<BoxCollider2D> ().enabled = false;
	yield return new WaitForSeconds(20);//after 20 secs  it will active the platform....
	GetComponent<SpriteRenderer> ().enabled=true;
	GetComponent<BoxCollider2D> ().enabled = true;
             playerjumpedOnPlatform=false;

}