how to create a Pause Button?

Please I want a Pause button using GUI i would like to pause and unpause the game! Thank you!

Add a canvas to the scene if you dont have one (Right click heirarchy → UI → Canvas), add a button to the canvas (right click canvas → UI → Button). Make this script and attach to button object.

using UnityEngine;
using UnityEngine.UI;  
public class PauseButton : MonoBehaviour {
    void Start() {
    public void TogglePause() {
        Time.timeScale = Mathf.Approximately(Time.timeScale, 0.0f) ? 1.0f : 0.0f;        

You can also set the OnClick through the editor in the button settings if you don’t want to do it through code.