Why isn't this script working? (Beginner in coding)

**I’m trying to make it so that when the player has destroyed 6 objects, the 6 objects will be noted as “true”. This doesnt seem to be working and I can’t figure out why. Please help. **

var hasDalek : boolean = false;
var hasMeteor : boolean = false;
var hasWire : boolean = false;
var hasCasing : boolean = false;
var hasDalekLight : boolean = false;
var hasPlans : boolean = false;



var Dalekgun : GameObject; 
var Meteor : GameObject; 
var Wire : GameObject; 
var Casing : GameObject; 
var DalekLight : GameObject; 
var Plans : GameObject; 
 
function Start () {
   if (hasDalek)
   {
      if (Dalekgun == null);
          (hasDalek) = true;
   
   }
   
      if (hasMeteor)
   {
      if (Meteor == null);
          hasMeteor = true;
   }
   
   	  if (hasWire)
   {
      if (Wire == null);
          hasWire = true;
   }
   
   	  if (hasCasing)
   {
      if (Casing == null);
          hasCasing = true;
   }
   
      if (hasDalekLight)
   {
      if (DalekLight == null);
          hasDalekLight = true;
   }
   
      if (hasPlans)
   {
      if (Plans == null);
          hasPlans = true;
   }
   
}

Because… it’s wrong?

Ok, I’m sorry about that. One of those days…

First [ never mind, boolean will do fine ]

Second, you have unnecessary parentheses on line 21.

Third, variables start with lowercase.

Fourth, you can’t put a semicolon after an if statement, you need nested brackets.

Fifth, even if you fix the syntax, nothing will be set to true unless it was already true.

Finally, this script doesn’t appear to actually do anything useful, even if it were correctly written.

That about covers it. Mainly, you need to brush up on how if statements work.
[edit] Missed your explanation first time. I’ll go ahead and fix your code so it works. The other critical failure in your script is that it runs only once, in Start(). It won’t run every time you destroy an object, so nothing will get updated.

var hasDalekGun : System.Boolean = false;
var hasMeteor : System.Boolean = false;
var hasWire : System.Boolean = false;
var hasCasing : System.Boolean = false;
var hasDalekLight : System.Boolean = false;
var hasPlans : System.Boolean = false;
 
var dalekGun : GameObject; 
var meteor : GameObject; 
var wire : GameObject; 
var casing : GameObject; 
var dalekLight : GameObject; 
var plans : GameObject; 


function Awake ()
{
dalekGun = GameObject.Find("TheDalekGunOrWhateverYouCalledIt");
}

function Update ()
{
CheckStuff ();
}
 
function CheckStuff () 
{
if (!hasDalekGun && !dalekGun)
    {
    hasDalekGun == true;
    }
// etc.

}

But still, I don’t think what you are doing is the proper way to go about it. When the item is picked up, right before you destroy it, you can set the appropriate boolean variable to “true”. There is no need to keep checking. If it is another script, just use dot notation.

at the start:
var nocs : NameOfControlScript;
drag on in the Inspector

then at the appropriate point in the script:

nocs.hasDalekGun = true;

function Start ()
{
if (Dalekgun != null)
{
hasDalek = true;
}
}

If I’m not mistaken, your code is trying to say, “If the GameObject ‘Dalekgun’ exists, then ‘nasDalek’ is True”? And then repeat for the rest.