Unidentified identifier 'Destroy'

Ok, here is a script, I keep getting an error at the bottom Unidentified identifier ‘Destroy’ like wth that’s a system function. what’s going wrong?

var s1 : GameObject;
var s2 : GameObject;
var s3 : GameObject;
var s4 : GameObject;

function Start(){
    health = maxhealth;

class Shield extends System.ValueType{
    var maxhealth : float;
    private var health : float;
    var go : GameObject;

var Shields : Shield[];
function Effect(ray : RaycastHit){
var hp = (health/maxhealth*100);
var rot = Quaternion.FromToRotation(Vector3.right, ray.normal);
if (hp <= 100 && hp >= 70){Instantiate(s1,ray.point,rot);}
else if (hp <= 70 && hp >= 50){Instantiate(s2,ray.point,rot);}
else if (hp <= 50 && hp >= 25){Instantiate(s3,ray.point,rot);}
else if (hp > 0){Instantiate(s4,ray.point,rot);}

function Damage(d : ShieldDamage){
    for (var s : Shield in Shields){
        if (s.go == d.shield){
            if (s.health <= 0){

function Kill(o : GameObject){
    while(o.transform.localScale.x < 50){


Well, another point why UnityScript is more confusing than helping :wink:

You called the script file Shield.js. Normally you don’t need the class construct in US but you can use it. In your case you used it and made the Shield class to be derived from System.ValueType. But this action will make your whole shield script no longer derive from MonoBehaviour and therefore it’s no longer a component. Your class is also no longer derived from UnityEngine.Object and that’s why Destroy is no longer “known” inside your class.

If the script above represents the shield class it can’t contain another shield class in itself. If shield.js should be a component you need to rename your data class.

Try Object.Destroy

That yield all by itself seems suspicious, what is the intent of that?