sentry gun help

I do not understand the coding for how to make the sentry gun shoot. The head of it follows me but it will not shoot.

here is the code.
var attackRange = 30.0;
var shootAngleDistance = 10.0;
var target : Transform;

function Start () {
if (target == null && GameObject.FindWithTag(“Player”))
target = GameObject.FindWithTag(“Player”).transform;

function Update () {
if (target == null)

if (!CanSeeTarget ())

var targetPoint = target.position;
var targetRotation = Quaternion.LookRotation (targetPoint - transform.position, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 2.0);

var forward = transform.TransformDirection(Vector3.forward);
var targetDir = target.position - transform.position;
if (Vector3.Angle(forward, targetDir) < shootAngleDistance)


function CanSeeTarget () : boolean
if (Vector3.Distance(transform.position, target.position) > attackRange)
return false;

var hit : RaycastHit;
if (Physics.Linecast (transform.position, target.position, hit))
	return hit.transform == target;

return false;


Can someone help, Thank you. (first Question)

Did you write this script? If not then you should probably learn scripting rather than copying somebody else’s code without understanding it. Anyway, this script only send a message. Another script is supposed to receive this message and fire.