For Loop to activate gameObjects one after the other
Hi, I need some help in restructuring my script so that i dont get the same error no more. I have a list of objects which has object that get activated one after the other one. when you clip on the object it has to be destroyed. So all of that work fine, but then, everytime I do press on the first object and it get destroyed, I get this error and the game stops: "MissingReferenceException: The object of type 'GameObject' 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."
In my case I would like to GameObject to be destroyed. So what could be a could option for this? Here is the script.
IEnumerator CaroutineFunction()
{
for (int t = 0; t < tapsToOpen.Count; t++)
{
yield return new WaitForSeconds(10);
tapsToOpen[t].SetActive(true);
messagesText.ToggleMessage();
timerManager.countDown();
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612052221im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Boolean, IEnumerator and SetActive probleme.BUG 2 Answers
If & Else If with == and && not working 0 Answers
Persistent Timers in Couroutines 0 Answers
Can we protect our codes with ienumerator against decompiling? 1 Answer
PowerUp Timer 0 Answers