Destroying scripts from GameObjects
Hi, I'm trying to do my very first card game, but I can't find a way to destroy a script from my gameobjects (cards). So I want to make an end turn function, so when it's called the player cant drag and drop their cards on the table.
 void EndTurn()
     {
         GameObject[] card = GameObject.FindGameObjectsWithTag ("Card");
         int maxcard = card.Length;
         Destroy(card [maxcard].GetComponents<Draggable> ());
         //drg = card.GetComponent<Draggable> ();
         //Destroy (drg);
 
     }
Any suggestions are much appreciated.
Update 1: I forgot to mention that in the script i don't have functions like Start, Update... so it can't be disabled.
Answer by Reichs_Industries · Aug 29, 2015 at 09:53 AM
So I used for loop to get every element from my array, then I destroyed them one by one.
 void EndTurn()
     {
         GameObject[] card = GameObject.FindGameObjectsWithTag ("Card");
         int maxcard = card.Length;
         for (int i = 0; i < maxcard;) {
             Destroy(card[i].GetComponent<Draggable>());
             i++;
         }
     }
Answer by Xephex · Aug 29, 2015 at 09:32 AM
Could you simply use this?
 scriptname.enabled = false;
Well, I forgot to mention that my script doesn't contanin functions like Update or Start... so it can not be disabled. For a couple of tryings I found a way to solve my problem.
Your answer
 
 
             Follow this Question
Related Questions
GUI Textures for each level Wave 1 Answer
Find if object is at a point? 1 Answer
Destroy object with dontdestroyonload 2 Answers
Find Position of Destroying Object ? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                