Help!

Hi I’m just started to learn javascript and I have lot of problems. Please help me with that: Object reference not set to an instance of an object#pragma strict

function Start(){

}
function OnCollisionEnter(collision : Collision) {
var obr : int = 0;
var pobr : Obrazenia = GetComponent(Obrazenia);
if (collision.relativeVelocity.magnitude > 2){
obr++;

pobr.wal(obr);
}
}

obrazenia script:

#pragma strict

function wal(a) {
guiText.text="obrazenia: " +a ;
}

The error is correct, get component doesnt create an instance it only grabs the component. lets say you had a script named SomeScript inside that script you have a function named DoSomething, you then would use the get component to access that script and call its functions this is where get component would come in handy.

What you want here is to instantiate the gameObject, something like this

var Obrazenia;
var pobr Instantiate(Obrazenia, transform.position, transform.rotation);

that is the very basics reasearch instantiate for more details

Thanks,
but I can’t understand how it work. What shoud I do ?

???/
Kolizja.js

#pragma strict

function OnCollisionEnter(collision : Collision) {
if (collision.relativeVelocity.magnitude > 2)
{
var skr : Obrazenia = GetComponent(Obrazenia);
var Obrazenia;
var skr Instantiate(Obrazenia, transform.position, transform.rotation);

}
}

Obrazenia.js

#pragma strict

function zzz(a,b,c)
{
guiText.text = "Obrazenia: " +a;
}

im not really sure what ur even trying to do…

Read some tutorials