Object reference not set to an instance of a object

Hey guys. Im new to Unity and could use some help

Here is the code and a picture of the problem

#pragma strict

private var lineTransform : Vector3;
private var startTransform : Vector3;

function Start () {
    lineTransform = transform.position;
    startTransform = transform.position;
}

function Update () {
    var hit : RaycastHit;
    var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));

    if (Input.GetKeyDown(KeyCode.Mouse0)) {
        if (Physics.Raycast(ray, hit, 100)) {
            Debug.DrawRay(startTransform, lineTransform, Color.red);
        }
    }
}

your camera hasnt got the tag of main so unity cant find it , just set the tag to main on your camera , or just use GetComponent().

I did what you said, but for some reason the when i shot it just shots where the camera started. Even though the camera follows the ball the shot comes from the cameras startpoint in the game?

That’s certainly odd. You say “I did what you said”, but he gave 2 suggestions; which did you do?

I did the tag first, but for some reason whenever i shot the “red line” only appears, at the cameras startpoint, when i start to roll around the camera follows, but the “Red line” keeps coming from the same position

I also did the GetComponent(Camera), but when i click the mouse the i cant move the ball or use any controls