Raycast shooting problem. Please Help!

Hey :p. I’m creating 3d shooting game, but my script about raycast shooting did’nt work. It’s it:

	function Update () {
		if (Input.GetMouseButtonDown(0)) {
			var hit: RaycastHit;
			var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			
			if (Physics.Raycast(ray, hit)) {
				Destroy(hit.gameobject);
			}
		}
	}

My problem is error, when i’m trying “throw” ray. It’s this error message: 1647793--102647--$g1pz5l.jpg

It’s every time when i trying press left button. :frowning:

PLEASE HELP!

PS. Sorry if my english is not perfectly.

Check if your camera has the “MainCamera” tag?

Thanks! It works now! :razz:

Once it worked. Fckin unity updates.