How to Load Scene on button click and after delay.

I need help in loading scene on button click and after delay. Can someone help me with this?

Make a script like this and add it to the button (Or really anywhere in the scene)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class TestScript : MonoBehaviour
	public void ButtonFunction()
	IEnumerator DelaySceneLoad()
		yield return new WaitForSeconds(3f); // Wait 3 seconds
		SceneManager.LoadScene("Scene2"); // Change to the ID or Name of the scene to load

Then, select the button and make it run the function you’ve just created by adding an OnClick Event and dragging the Component onto it, then selecting the function that loads the scene after a timer.
alt text