don't destoy object some scene

Hello!i have a question, i have to scenes and i want to one scene to pass my canvas and to another don’t pass it,i try DontDestroyOnLoad() and to one scene my canvas pass, but he pass and to another scene,how i can stop to pass one scene?

if I understood correctly you want your canvas to be active in one scenen but don’t want to be active on another scene …
Create a script called CanvasActivator then attach it to your canvas and change the values on your own…

Paste this code in CanvasActivator then add your scene names that you want to activate your canvas in the inspector(You must add scenes in build settings) :

using UnityEngine;
using System.Linq;
using UnityEngine.SceneManagement;
public class CanvasActivator : MonoBehaviour {

    public string[] scenesToActivate;

    private void Awake()
    {
        DontDestroyOnLoad(gameObject);
        SceneManager.sceneLoaded += OnSceneLoaded;
    }
    private void OnSceneLoaded(Scene scene,LoadSceneMode mode)
    {
        if (scenesToActivate.ToList().Contains(scene.name))
        {
            GetComponent<Canvas>().enabled = true;
        }
        else
        {
            GetComponent<Canvas>().enabled = false;
        }
    }
    private void OnApplicationQuit()
    {
        SceneManager.sceneLoaded -= OnSceneLoaded;
    }
}