i have a button to restart the same scene but it dont works (with images)

i have many many things but no one of them worked

i had created an empty gameobject and attached this script to it then put the gameobject into the button’s ONCLICK and then choosen the public function of the script

then when i play the the game the button dont work i dont understand why

i have only one scene and when the players die the button be activated 'i have done this in onother script"
i click the button to restart the scene…

this is he script:

using UnityEngine.SceneManagement;
using UnityEngine;

public class RESTART : MonoBehaviour {

public void restart()
	//SceneManager.LoadScene (SceneManager.GetActiveScene ().name);

	//Scene loadedLevel = SceneManager.GetActiveScene ();
	//SceneManager.LoadScene (loadedLevel.buildIndex);




Hi !

Is your scene in the “Scenes in build” list (in the built settings window) ?

Why is your script commented out?

Try using the following code:



If it doesn’t work make sure that the button is getting called by some Debug.Log() withing the restart function.

SceneManager.LoadScene (SceneManager.GetActiveScene ().name);

this has to work?

if it’s not working try that


Same code, but working with Unity 5.6.0f3

From what I see in images, you havn’t attached the script to a gameobject and you directly draged it from Project panel into the event slot in inspector (tell me if I’m wrong).

you need to drag the script on a gameobject and drag that gameobject into the slot in the event part of the button

thank you so much!! I have been trying to figure this out forever :slight_smile: