- Home /
 
              This question was 
             closed Jul 30, 2013 at 01:33 AM by 
             Drshk7 for the following reason: 
             
 
            The question is answered, right answer was accepted
 
               Question by 
               Drshk7 · Nov 13, 2012 at 04:23 AM · 
                stringidentifierunknownhealth  
              
 
              HealthPack Script Problem...
It says unknown identifier 'health' and cannot convert string blah blah to gameObject in (21, 41) wrote this code myself (im a begginer) please help. here's code:
 #pragma strict
 
 var HealthPack : GameObject;
 var Healthnum = 10;
 var player : GameObject;
 
 function Update () 
 {
  var healthScript : Status = GetComponent(Status);
  Health = healthScript.Health;
  if(Healthnum == 0)
  {
   die();
  }
 }
 
 function OnTriggerEnter ( hit : Collider )
 {
     if(hit.gameObject.tag == "Player")
     {
         player = hit.gameObject.tag;
         AddHealth ();
     }
 }
 
 function AddHealth ()
 {
  Health += Healthnum;
  Healthnum -= Healthnum;
 }
 
 function die ()
 {
     Destroy(gameObject);
 }
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by AlucardJay · Nov 13, 2012 at 06:39 AM
unknown identifier 'Health'
You are using a variable in that script , but havn't declared it anywhere =]
 var Health : float = 0;
 
               then this is wrong player = hit.gameObject.tag;, you want to store a reference to the GameObject, not the tag :
 player = hit.gameObject;
 
              Follow this Question
Related Questions
Unknown Identifier maxSlope 1 Answer
Health script? That uses tags 1 Answer
Help with dammage script 3 Answers
My health decreases to fast. 1 Answer
Why does SystemInfo.deviceUniqueIdentifier fail to return the same string? 0 Answers