The object of type 'Transform' has been destroyed but you are still tryin

Hello all, i need some help here if anyone has the time.

I added some scripts with animation to a panel that is being active when the game win.
but if i have the animation it gives me an error the game keeps playing. if i remove the animation then it finishes. Can anyone tell me how can i fix my problem? Thanks.

the error i am getting is:
MissingReferenceException: The object of type ‘Transform’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Component.GetComponent[Renderer] () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineComponentBindings.gen.cs:45)

the whole script is:

#pragma strict
#pragma implicit
#pragma downcast

import UnityEngine.UI;
import MadLevelManager;

var scoreToWin:float = 7000;
var timeToWin:float = 180;
var delayBewteenDestroy: float = 0.03f; //used to wait 0.03 second before each ball destroy, when you win
var winLostText:Text;
var timeText:Text;
var container:GameObject;
var particles:ParticleSystem;
var PanelWin:GameObject;
var PanelLose:GameObject;
var ButtonPause:GameObject;

private var gameOver:boolean = false;
private var timeLeft:float = 0;
private var reactionTime:float = 0.0f;

private var clickDetecting:Clickdetecting;

function Start()
{
clickDetecting = GetComponent.();
PanelWin.active = false;
PanelLose.active = false;
}

function Update () {
if(!gameOver)
{
reactionTime += Time.deltaTime;
roundedRT = Mathf.Floor(reactionTime);
timeLeft = timeToWin - roundedRT;
timeText.text = “” + timeLeft;

if(timeLeft <= 0 && clickDetecting.scoreCounter >= scoreToWin)
{
winLostText.text = “YOU WON !”;
winLostText.enabled = true;//change to true to make it active when you win
Destroy(); //call destroying function
PanelWin.active = true;
ButtonPause.active = false;
clickDetecting.enabled = false;//disable clicking
container.GetComponent.().enabled = false;//disable instantiation
MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
//PlayerPrefs.SetInt(“UnlockLevel”+Application.loadedLevel.ToString(), Application.loadedLevel); (Delete the // at the start of this line to set to true.
}
else if(timeLeft <= 0 && clickDetecting.scoreCounter < scoreToWin){
winLostText.text = “YOU LOST!”;
winLostText.enabled = false;//change to true to make it active when you lose
Killer.enable = false;
PanelLose.active = true;
clickDetecting.enabled = false;//disable clicking

for (var child:Transform in container.transform){
child.gameObject.GetComponent.().constraints = RigidbodyConstraints.None;
}

Physics.gravity = Vector3(0, -10, 0.1);

container.GetComponent.().enabled=false; //disable instantiation
Ballsound.volumeUp = true;
enabled = false; //disable time cowntdown
}
}
}

function Destroy(){
gameOver = true;
var children = container.GetComponentsInChildren.();
for (var i:int = 1; i < children.length; i++){
particles.startColor = children*.GetComponent.().material.color; //match particles color to current destroyed ball’s color*
Instantiate(particles, children_.position, children*.rotation); //instantiate particle*
Destroy(children*.gameObject); //destroy the ball*
yield WaitForSeconds(delayBewteenDestroy); //wait 0.03 second before each ball destroy
}_

enabled = false;
}

Now line number would be a great deal, right?
Wait!
Wasn’t there something?
:sunglasses:
Ding!

#pragma strict
#pragma implicit
#pragma downcast

import UnityEngine.UI;
import MadLevelManager;

var scoreToWin:float = 7000;
var timeToWin:float = 180;
var delayBewteenDestroy: float = 0.03f; //used to wait 0.03 second before each ball destroy, when you win
var winLostText:Text;
var timeText:Text;
var container:GameObject;
var particles:particleSystem;
var PanelWin:GameObject;
var PanelLose:GameObject;
var ButtonPause:GameObject;

private var gameOver:boolean = false;
private var timeLeft:float = 0;
private var reactionTime:float = 0.0f;

private var clickDetecting:Clickdetecting;

function Start()
{
clickDetecting = GetComponent.<Clickdetecting>();
PanelWin.active = false;
PanelLose.active = false;
}


function Update () {
if(!gameOver)
{
reactionTime += Time.deltaTime;
roundedRT = Mathf.Floor(reactionTime);
timeLeft = timeToWin - roundedRT;
timeText.text = "" + timeLeft;

if(timeLeft <= 0 && clickDetecting.scoreCounter >= scoreToWin)
{
winLostText.text = "YOU WON !";
winLostText.enabled = true;//change to true to make it active when you win
Destroy(); //call destroying function
PanelWin.active = true;
ButtonPause.active = false;
clickDetecting.enabled = false;//disable clicking
container.GetComponent.<Instantiator>().enabled = false;//disable instantiation
MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
//PlayerPrefs.SetInt("UnlockLevel"+Application.loadedLevel.ToString(), Application.loadedLevel); (Delete the // at the start of this line to set to true.
}
else if(timeLeft <= 0 && clickDetecting.scoreCounter < scoreToWin){
winLostText.text = "YOU LOST!";
winLostText.enabled = false;//change to true to make it active when you lose
Killer.enable = false;
PanelLose.active = true;
clickDetecting.enabled = false;//disable clicking

for (var child:Transform in container.transform){
child.gameObject.GetComponent.<Rigidbody>().constraints = RigidbodyConstraints.None;
}

Physics.gravity = Vector3(0, -10, 0.1);


container.GetComponent.<Instantiator>().enabled=false; //disable instantiation
Ballsound.volumeUp = true;
enabled = false; //disable time cowntdown
}
}
}

function Destroy(){
gameOver = true;
var children = container.GetComponentsInChildren.<Transform>();
for (var i:int = 1; i < children.length; i++){
particles.startColor = children.GetComponent.<Renderer>().material.color; //match particles color to current destroyed ball's color
Instantiate(particles, children.position, children.rotation); //instantiate particle
Destroy(children.gameObject); //destroy the ball
yield WaitForSeconds(delayBewteenDestroy); //wait 0.03 second before each ball destroy
}

enabled = false;
}

You probably should rename you Destroy function.