Shooting script no working correctly

Here’s the script:

var shotSound: AudioClip; // drag a shot sound here, if any
var bloodPrefab: GameObject; // drag the blood prefab here, if any
var sparksPrefab: GameObject; // drag the sparks prefab here, if any
var effect : GameObject;
var waterPrefab : GameObject;

function Shoot(){
    if (shotSound) audio.PlayOneShot(shotSound); // play the shot sound
    var hit: RaycastHit;
    if (Physics.Raycast(transform.position, transform.forward, hit)){
        // prepare rotation to instantiate blood or sparks
        var rot = Quaternion.FromToRotation(Vector3.up, hit.normal);
        if (hit.transform.tag == "Enemy"){ // if enemy hit...
            if (bloodPrefab) Instantiate(bloodPrefab, hit.point, rot); // make it bleed...
            hit.collider.gameObject.GetComponent(Animator).SetBool("Dying", true);
        } // and consume its health
        if (hit.transform.tag == "Water"){
            Instantiate(waterPrefab, hit.point, rot);
        else { // otherwise emit sparks at the hit point
            if (sparksPrefab) Instantiate(sparksPrefab, hit.point, rot);

function Update(){
    if (Input.GetButtonDown("Fire2")){
    	var fx : GameObject = Instantiate(
   		effect, transform.position, transform.rotation );

When I shoot the enemy, this error message pops up:

MissingMethodException: UnityEngine.RaycastHit.Destroy
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher ()
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.Create ()
Boo.Lang.Runtime.RuntimeServices.DoCreateMethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object[] args)
Boo.Lang.Runtime.RuntimeServices.CreateMethodDispatcher (System.Object target, System.String name, System.Object[] args)
Boo.Lang.Runtime.RuntimeServices+<Invoke>c__AnonStorey15.<>m__9 ()
Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args)
UnityScript.Lang.UnityRuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args, System.Type scriptBaseType)
RayCast.Shoot () (at Assets/Standard Assets/Tutorial de shooter/RayCast.js:16)
RayCast.Update () (at Assets/Standard Assets/Tutorial de shooter/RayCast.js:29)

I know the problem is in this line


but I don’t know how to solve it. Please can anybody help me???

PD: Sorry for my bad English

You are trying to destroy the character controller attached to this specific game object? Try this:


If for some reason you have trouble with this, you can do:

hit.collider.GetComponent(CharacterConroller).enabled = false;

This will disable the character controller, not destroy it.