Trying to set up a trigger zone to protect a player after respawn.

I have set up a trigger zone to protect a play from being attacked after they respawn in the safe area. The script that marks the area is:
function OnTriggerEnter(col : Collider)
{
if(col.gameObject.tag == “FemaleHuman” || “MaleHuman”)
{
HealthAndDamage.inOppSafeZone = true;
}
}

function OnTriggerExit(col : Collider)
{
if(col.gameObject.tag == “FemaleHuman” || “MaleHuman”)
{
HealthAndDamage.inOppSafeZone = false;
}
}
for the Vamp area.
function OnTriggerEnter(col : Collider)
{
if(col.gameObject.tag == “FemaleVamp” || “MaleVamp”)
{
HealthAndDamage.inOppSafeZone = true;
}
}

function OnTriggerExit(col : Collider)
{
if(col.gameObject.tag == “FemaleVamp” || “MaleVamp”)
{
HealthAndDamage.inOppSafeZone = false;
}
}
for the Human area.

both call the HealthAndDamage Script:
//Variables___________________________________
private var parentObject : GameObject;
var myAttacker : String;
var team : String;
var JustBeenHit : boolean = false;
var hitByBullet : boolean = false;
static var inOppSafeZone : boolean = false;
private var destroyed : boolean = false;
private var gunDamage : float = 10;
private var SafeZoneDamage : float = 3;
var myHealth : float = 100;
var maxHealth : float = 100;
private var healthRegenRate : float = 0.75;

// Use this for initialization
function Start ()
{
parentObject = transform.parent.gameObject;
}

// Update is called once per frame
function Update ()
{
if(JustBeenHit == true)
{
var gameManager : GameObject = GameObject.Find(“GameManager”);
var dataScript : PlayerDataBaseScript = gameManager.GetComponent(PlayerDataBaseScript);
for(var i : int = 0; i < dataScript.PlayerList.Count; i++)
{
if(myAttacker == dataScript.PlayerList*.playerName)*

  •   	{*
    

_ if(int.Parse(Network.player.ToString()) == dataScript.PlayerList*.networkPlayer)_
_
{_
_
if(hitByBullet == true && destroyed == false)_
_
{_
_
myHealth = myHealth - gunDamage; _
_
networkView.RPC(“UpdateMyCurrentAttackerEverywhere”, RPCMode.Others, myAttacker);_
_
networkView.RPC(“UpdateMyCurrentHealthEverywhere”, RPCMode.Others, myHealth);_
_
}_
_
}_
_
}_
_
}_
_
JustBeenHit = false;_
_
}_
_
if(inOppSafeZone == true && destroyed == false)_
_
{_
_ myHealth = myHealth - SafeZoneDamage * Time.deltaTime;_
_
networkView.RPC(“UpdateMyCurrentHealthEverywhere”, RPCMode.Others, myHealth);_
_
}_
_
if(myHealth <= 0 && networkView.isMine == true)_
_
{_
_
var spawnManager : GameObject = GameObject.Find(“SpawnManager”);_
_
var spawnScript : SpawnScript = spawnManager.GetComponent(SpawnScript);_
_
spawnScript.IamDead = true;_
_
Network.RemoveRPCs(Network.player);_
_
networkView.RPC(“DestroySelf”, RPCMode.All);_
_
}_
_
if(myHealth < maxHealth)_
_
{_
_ myHealth = myHealth + healthRegenRate * Time.deltaTime;_
_
}_
_
if(myHealth > maxHealth)_
_
{_
_
myHealth = maxHealth; _
_
}_
_
}_
_
@RPC*_
function UpdateMyCurrentAttackerEverywhere (attacker : String)
{
* myAttacker = attacker; *
}
@RPC
function UpdateMyCurrentHealthEverywhere (health : float)
{
* myHealth = health; *
}
@RPC
function DestroySelf ()
{
* Destroy(parentObject); *
}
*@script RequireComponent(NetworkView) *
The problem is when you spawn in the safe area you start taking damage. Please help.

Why not timing an invincibility period?

var canGetHit:boolean;
function Respawn(){
  //your stuff to respawn
  canGetHit = false;
  Invoke("ResetGetHit",5.0f);
}

function ResetGetHit(){
  canGetHit = true;
}

function Damage(int damage){
   if(canGetHit)
       health-=damage;
}

canGetHit needs to be true for damage to be applied. As you respawn your guy after death, it is set to false. Invoke will be called in 5sec and will set it back to true. Your guy is invincible for 5sec.

function OnTriggerEnter(col : Collider) { if(col.gameObject.tag == “FemaleHuman” || “MaleHuman”) { HealthAndDamage.inOppSafeZone = true; } }

function OnTriggerExit(col : Collider) { if(col.gameObject.tag == "FemaleHuman" || "MaleHuman") { HealthAndDamage.inOppSafeZone = false; } } for the Vamp area. function OnTriggerEnter(col : Collider) { if(col.gameObject.tag == "FemaleVamp" || "MaleVamp") { HealthAndDamage.inOppSafeZone = true; } }

function OnTriggerExit(col : Collider) { if(col.gameObject.tag == "FemaleVamp" || "MaleVamp") { HealthAndDamage.inOppSafeZone = false; } } for the Human area.

both call the HealthAndDamage Script: //Variables___________________________________ private var parentObject : GameObject; var myAttacker : String; var team : String; var JustBeenHit : boolean = false; var hitByBullet : boolean = false; static var inOppSafeZone : boolean = false; private var destroyed : boolean = false; private var gunDamage : float = 10; private var SafeZoneDamage : float = 3; var myHealth : float = 100; var maxHealth : float = 100; private var healthRegenRate : float = 0.75;

// Use this for initialization function Start () { parentObject = transform.parent.gameObject; }

// Update is called once per frame function Update () { if(JustBeenHit == true) { var gameManager : GameObject = GameObject.Find("GameManager"); var dataScript : PlayerDataBaseScript = gameManager.GetComponent(PlayerDataBaseScript); for(var i : int = 0; i < dataScript.PlayerList.Count; i++) { if(myAttacker == dataScript.PlayerList<em>.playerName) { if(int.Parse(Network.player.ToString()) == dataScript.PlayerList_.networkPlayer) { if(hitByBullet == true && destroyed == false) { myHealth = myHealth - gunDamage; networkView.RPC("UpdateMyCurrentAttackerEverywhere", RPCMode.Others, myAttacker); networkView.RPC("UpdateMyCurrentHealthEverywhere", RPCMode.Others, myHealth); } } } } JustBeenHit = false; } if(inOppSafeZone == true && destroyed == false) { myHealth = myHealth - SafeZoneDamage * Time.deltaTime; networkView.RPC("UpdateMyCurrentHealthEverywhere", RPCMode.Others, myHealth); } if(myHealth maxHealth) { myHealth = maxHealth; } }_</em>

@RPC function UpdateMyCurrentAttackerEverywhere (attacker : String) { myAttacker = attacker; }

@RPC function UpdateMyCurrentHealthEverywhere (health : float) { myHealth = health; }

@RPC function DestroySelf () { Destroy(parentObject); }

@script RequireComponent(NetworkView)
This would help make it more visible than it already is.
=========================================================