How do OnTrigger Colliders work in JS?

I’m trying to make a script that moves a certain game objects as long as the player is inside of a certain collider. Here’s the script…

#pragma strict
var UI : GameObject;
var enemy : GameObject;
var fadeTime : float = 0.20763;
var startPosition : float = 78.9;
function Start ()
{
    UI.GetComponent.<RectTransform>().anchoredPosition.y = startPosition;
}
function Update ()
{
  OnTriggerStay(other: Collider) {
    if (other.attachedRigidbody)
}
        {
           UI.GetComponent.<RectTransform>().anchoredPosition.y -= 0.1 * Time.deltaTime / fadeTime;
        } 
}

But, I have no idea how to work the OnTrigger Colliders. I pulled that part of the script from the Unity docs adn I have no Idea how to use it. What do I replace? Where do I put everything?

function Update ()
{
  OnTriggerStay(other: Collider) {
    if (other.attachedRigidbody)
}
        {
           UI.GetComponent.<RectTransform>().anchoredPosition.y -= 0.1 * Time.deltaTime / fadeTime;
        }
}

What is this section of code doing? OnTrigger is a predefined function, If you want to use the UI component in the OnTriggerStay method, do it like this

function Update ()
{
}
function OnTriggerStay(other: Collider) {
    if (other.attachedRigidbody)
    {
        UI.GetComponent.<RectTransform>().anchoredPosition.y -= 0.1 * Time.deltaTime / fadeTime;
    }
}

Note that OnTriggerStay calls the method EVERY FRAME you are in the collider, OnTriggerEnter is only the first frame you enter.

I changed it and go no errors, but it just doesn’t do anything. Here’s the script…

#pragma strict
var UI : GameObject;
var fadeTime : float = 0.20763;
var startPosition : float = 78.9;
function Start ()
{
    UI.GetComponent.<RectTransform>().anchoredPosition.x = startPosition;
}
function Update ()
{
}
function OnTriggerStay(other: Collider) {
    if (other.attachedRigidbody)
    {
        UI.GetComponent.<RectTransform>().anchoredPosition.x -= 0.1 * Time.deltaTime / fadeTime;
    }
}

I have a rigidbody on my player, and the script is attached to collider. What’s wrong?

Nevermind, I changed -=0.1 to +=0.1 and It works fine! Thanks!