Pause, Unpause

Okay, so I want to be able to pause and unpause my game (not using a GUI text, but instead by just pressing P) and here is my coding so far…

using UnityEngine;
using System.Collections;

public class Pause : MonoBehaviour {
	public bool paused = false;
	void Start ()
	{
		paused = false;
		Time.timeScale = .1f;
	}
	// Update is called once per frame
	void Update () 
	{
		if (Input.GetKeyDown ("p") && paused == false)
		{
			Time.timeScale = 0;
			paused = true;
		}
		if (Input.GetKeyDown ("p") && paused == true)
		{
			Time.timeScale = 1;
			paused = false;
		}
	}
}

btw it’s in C#. It won’t pause but when I hit the P button it goes from Time.timeScale = .1f; to Time.timeScale = 1;

How do I fix that (relativley new to this and I can’t find the answer anywhere, trust me.)

So think about it. To begin you have paused set to false. When you press the p key, your test at line 14 will pass, so you’ll set paused to true. Then, at line 19, you test if the p key is pressed (it was) and if paused is true (it is). So you’ll always set paused to false if the p key is pressed. So, at line 19 do an else if.