Script that makes a user restart the level if they don't complete the objective

How can I make a script so that if a user doesn’t collect all of the items, they have to restart the level again.

An easy way to do it would be to figure out the total number of items in the scene. After that increment on a total number of items collected(or decrement, whatever you are more comfortable with).

Now something like this will help get you started but there are sooooo many different ways you can solve the issue you have.

Each item you want to “collect” must have a Collider on it with IsTrigger enabled.

private int totalItemsCollected;

private int totalItems = 10; //Whatever the total number of items you have in the scene is
	//Call this at the very end of the level
	private void TotalCollectedItemsCheck()
		if(totalItemsCollected < totalItems)

    private void OnTriggerEnter(Collider col)
    		if( == "itemCollected")
    			//Increment whenever you collect an item