How to delete instantiated objects that a cube touches

I’m instantiating my map for an infinite runner, but after a it starts lagging so I made a cube with a Box Collider and EventSystem and I checked Is Trigger. But the code wont work and it doesn’t destroy anything it touches, so how do i make it destroy anything it touches.

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

public class MapDestroy : MonoBehaviour {

    private void OnTriggerEnter(Collision other)
        if (other.gameObject.tag == "MapDestroy")


just change private void OnTriggerEnter(Collision other) to private void OnCollisionEnter(Collision other)
and also if you want to use OnCollisionEnter your colliders should not be trigger , so they can’t hit eachother.if you want them to be trigger you can use private void OnTriggerEnter(Collider other)
hope it helps :slight_smile: