null reference exception ... help!

nullreferenceexception object reference not set to an instance of an object

please help im a beginner and my head is about to explote by this i dont see the trouble in the code

var SplashObject : GameObject;
var UseRotation: boolean = false;

function Update () {
 	if(Input.GetButtonDown("Fire1")){
 		var hit : RaycastHit;
 		if (Physics.Raycast(Camera.main.transform.position,Camera.main.transform.foward, hit, 1000)){
 			var pos : Vector3 = hit.point;
 			var rot : Quaternion = Quaternion.identity;
 			if( UseRotation == true)
 			   rot = Quaternion.FromToRotation(Vector3.up, hit.normal);
 			Instantiate(SplashObject,pos,rot);
         }
     }
}

Without more info, I’m betting you never assigned SpalshObject in the Inspector

line number 9, on the raycast
I gave it test, and the ray casting is giving him problems.
Camera.main.transfom.foward is returning null becuase he spelled forward wrong. lol

here the working code:

var SplashObject : GameObject;
var UseRotation: boolean = false;
 
 
 
function Update () {

    if(Input.GetButtonDown("Fire1")){

        var hit : RaycastHit;
        if (Physics.Raycast(Camera.main.transform.position,Camera.main.transform.forward, hit, 1000)){
            var pos : Vector3 = hit.point;
            var rot : Quaternion = Quaternion.identity;
            if( UseRotation == true)
                rot = Quaternion.FromToRotation(Vector3.up, hit.normal);
            Instantiate(SplashObject,pos,rot);
        }
    }
}

null references are the most common errors I’ve ever seen, especially here in Unity.
null references mean your aren’t referencing something or something your referecing is null. best way to fix them is to check what vars are null using if
statements and print(“this var is null”)
also DaveA has a point , you did’t really give enough info which can infuriate people. which is probably he deleted my half written answer lol.

anyways hope this helps

Null Reference Exception Error - Unity,C# - Stack Overflow <= classic lols