# player not moving after respawn(java script)

**URL:** https://discussions.unity.com/t/player-not-moving-after-respawn-java-script/42364
**Category:** Questions & Answers
**Created:** [May 16, 2012, 1:08am UTC](https://discussions.unity.com/t/player-not-moving-after-respawn-java-script/42364 "2012-05-16T01:08:18Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![thenachotech1113](https://avatars.discourse-cdn.com/v4/letter/t/8797f3/32.png) [@thenachotech1113](https://discussions.unity.com/u/thenachotech1113)
#### Post date: [May 16, 2012, 1:08am UTC](https://discussions.unity.com/t/player-not-moving-after-respawn-java-script/42364/1 "2012-05-16T01:08:18Z")

</div>

hey, i realy neeed help with this, my player is not moving after respawning,the game is playing, what can I do.

```
private var dead = false;
var health = 100;
var damage = 10;

function OnControllerColliderHit(hit : ControllerColliderHit) 
{    
	if (hit.gameObject.tag == "fallout")
	{
        dead = true;
	}
	
	if (hit.gameObject.tag == "bullet" )
	{
	    health -= 10;
	}
	if (health < 1 )
	{
	    dead = true;
	}
}

function Update()
{
		if (dead) 
		    health = 100;
		transform.position = Vector3(-9,2,-48);
		dead = false;
}

```

---

<div class="post-metadata">

### Author: ![syclamoth](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@syclamoth](https://discussions.unity.com/u/syclamoth)
#### Post date: [May 16, 2012, 1:13am UTC](https://discussions.unity.com/t/player-not-moving-after-respawn-java-script/42364/2 "2012-05-16T01:13:37Z")

</div>

Is this the script that respawns the character? Try putting braces around that ‘if(dead)’ bit- I’ve fixed up the formatting to better describe what will happen there. Without the braces around that part, it will reset the position _every frame_, preventing you from moving, and it will also prevent damage (because it resets the ‘dead’ flag every frame as well).

Try this:

```
function Update()
{
       if (dead)
       {
           Debug.Log("Died, Respawning!");
           health = 100;
           transform.position = Vector3(-9,2,-48);
           dead = false;
       }
}

```
