Coins keep goin up

I have a script in which I have a coins counter for when you’re playing the game and then a totalCoins item for your total coins when you die. The only problem is that when I die, since the script is in a fixedupdate, the coins keep goin up. The script is below.

	if (!dead) {
		forwardMovementSpeed += (Time.deltaTime * .02f);
		Vector2 newVelocity = rigidbody2D.velocity;
		newVelocity.x = forwardMovementSpeed;
		rigidbody2D.velocity = newVelocity;
	} else {
		totalCoins = PlayerPrefs.GetInt("totalCoins") + coins;
		PlayerPrefs.SetInt("totalCoins", totalCoins);
		forwardMovementSpeed -= Time.deltaTime;
		if(forwardMovementSpeed <= 0){
			forwardMovementSpeed = 0;			
		}
	}

How do I make it so it checks if it has already added the coins from the game you just played? That way the coins from the last game will only be added once instead of repetitive addition.

Just set the totalCoins wherever you set the variable dead to true. This way it will only be updated whenever you die.