I’m making a game with a pause menu, so i use timescale= 0; to pause the game, but it doesn’t work.
how should i do this?
using UnityEngine;
using System.Collections;
public class PauseMenu : MonoBehaviour {
public GameObject PauseUI;
private bool paused = false;
void Start(){
PauseUI.SetActive(false);
Time.timeScale = 1;
}
void Update(){
if (Input.GetKeyDown(KeyCode.P)){
paused = !paused;
}
if(paused){
PauseUI.SetActive(true);
Time.timeScale = 0;
}
if(!paused){
PauseUI.SetActive(false);
Time.timeScale = 1;
}
}
}
Here’s The code for a pause menu in a game I’m making. Some of it is similar to your code and so far it is working. You could use parts of it (the time scale part) It might fix it. I have used an object called ‘PauseMenuHolder’ to have the UI on.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class PauseScript : MonoBehaviour
{
GameObject PauseMenuHolder;
bool paused;
void Start()
{
paused = false;
PauseMenuHolder = GameObject.Find("PauseMenuHolder");
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
paused = !paused;
}
if (paused)
{
PauseMenuHolder.SetActive(true);
Time.timeScale = 0;
}
else if (!paused)
{
PauseMenuHolder.SetActive(false);
Time.timeScale = 1;
}
}
public void Resume()
{
paused = false;
}
public void MainMenu()
{
Application.LoadLevel(1);
}
public void Quit()
{
Application.Quit();
}
}
Hope I helped in some way 
@SuperEpicDubstepGlassesOfPower Thanks, but the problem is still there. In the background you can move the ball, you can just play further.