acces variables from other script

I'm trying to acces a variable out of an other script, and i did find something that should work, but i don't know how exactly

This is the code: var feather : Transform; var script : TrackItems; script = GetComponent("TrackItems");

function OnTriggerEnter () { Destroy(feather.gameObject); script.feathers (script.feathers -1); }

I think it's clear what i want to happen, i just don't know how to Exactly do this, anyone who can help?

Create an empty GameObject and call it GameState and attach your TrackItems script to it. Set the tag of the GameState object to "GameController" in the inspector.

Your feather object must have a collider set as a trigger.

Attached this script to the feather:

//get the itemTracking Script
var itemTracker; 

function Start()
{
   itemTracker = GameObject.FindWithTag("GameController").GetComponent(TrackItems);
}

function OnTriggerEnter ()
{
   itemTracker.feathers -= 1; //subtract 1 from feathers in TrackItems
   Destroy(gameObject);
}

I got it working in an other way, here's what i have done:

//get the itemTracking Script var itemTracker; itemTracker = GameObject.FindWithTag("GameController").GetComponent(TrackItems);

function OnTriggerEnter () { itemTracker.feathers -= 1; //subtract 1 from feathers in TrackItems Destroy(gameObject); }