2 players in a trigger losing reference to player 1

I have this fall death script that can be triggered by 2 players at the same time,
resulting in one player not dieing because its reference is overwritten.

Can I instantiate the script for each player or how can i sove this issue?

Small example:

private var player : PlayerScript;


function OnTriggerEnter(thisCollider :Collider) :void
{
	player = thisCollider.GetComponent(PlayerScript);
	Kill();
}


function Kill() :IEnumerator
{
	// Wait for camera effects
	yield WaitForSeconds (5);
	player.PlayerDeath(); 
}

Because there is a 5 second delay the first player will not die if the second player enters the trigger before the 5 seconds are over.

My game has 2 charachters and the player can switch between them.
And I asume thiss will give multiplay trouble as well (up to 8 players)

IEnumerator doesn’t depend upon it’s previous call. Every call to coroutine is a separate thread. The problem here is that you are making the same variable to destroy (or whatever you do in PlayerDeath()).
If you have two different players, I’d suggest you should do this:

function OnTriggerEnter(thisCollider :Collider) :void
{
    if(thisCollider.tag == "player1")
        Kill(thisCollider.GetComponent(PlayerScript));
    else if(thisCollider.tag == "player2")
        Kill(thisCollider.GetComponent(PlayerScript));    
}
 
 
function Kill(thisPlayer :Collider) :IEnumerator
{
    // Wait for camera effects
    yield WaitForSeconds (5);
    thisPlayer.PlayerDeath(); 
}

This is untested code, but should work.