Script reference?

Hi,

I’m new to unity and i’m really stuck in my game. Whenever i shoot an object, i want to add 1 point to the variable score that is saved in a script of another GameObject. I think i need script referencing here, but i realy don’t now how to do that. (declaring varialbles, calling other scripts and functions,…)
I tried a lot of thinks, but nothing worked out. Can you guys help me?

Thanks

There is two ways to do this.

In your script declare this somewhere:

public ScriptName m_ScoreTally;

Then in the editor you can drag and drop the object this script is attached to which will link the two.

Another more dynamic approach is setting an objects tag then do the following:

ScriptName script = (ScriptName) GameObject.FindWithTag( “TagName” ).GetComponent( typeof( ScriptName ) );

The first way is the simpler option.

This will give you a start into scripting: http://forum.unity3d.com/threads/34015-Newbie-guide-to-Unity-Javascript-(long)