Platform Control

Hello. I have written a simple platform script that works by replacing a tile with an identicle tile without a collider. Is there anyway to make it only work if you hit a trigger collider? The problem is that if I save this in my project and create multiple copies they will all follow the script at the same time. Please help.

var Platform1 : GameObject;
var Platform2 : GameObject;

function Start () {
	Platform1.active = true;
	Platform2.active = false;

}

function Update () {
	if(Input.GetMouseButtonDown(1)){
		Platform1.active = false;
		Platform2.active = true;
	
}
	if(Input.GetMouseButtonUp(1)){
		Platform1.active = true;
		Platform2.active = false;
	}
}

I’m not exactly sure what you’re trying to do. Would something like this work?

var Platform1 : GameObject;
var Platform2 : GameObject;
var controlActive : bool;
 
function Start () 
{
    controlActive = false;
    Platform1.active = true;
    Platform2.active = false;
}
 
function Update () 
{
    if(controlActive)
    {
        if(Input.GetMouseButtonDown(1))
        {
           Platform1.active = false;
           Platform2.active = true;
        }

        if(Input.GetMouseButtonUp(1))
        {
           Platform1.active = true;
           Platform2.active = false;
        }
    }
}

function onTriggerEnter(col : Collider)
{
    controlActive = true;
}

function onTriggerExit(col : Collider)
{
    controlActive = false;
}

Note: I normally code in c#, so there might be compiler errors here, sorry.