Unity Button callback doesnt work.

So iam trying to make an script which allows you to grab an flashlight from your inventory. When you click the button saying flashlight it should do this

  1. Activate the flashlight.
  2. Remove the UI
  3. Give the person the controls back
  4. Remove mouse fro the screen / unfreeze it.
    So I have been trying to make an code and saw this post from unity.
    Unity - Scripting API: UI.Button.onClick
    Ive tried to recreate that and it didn’t work. Then I copied and paste it it didn’t work either.
    Here is the code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InventoryFlashLight : MonoBehaviour
{
    public GameObject Item;
    public GameObject UiItem;
    public bool paused;
    public Button yourbutton;


    void Start()
    {
        myMove = GetComponent<FirstPersonAIO>();
        Button btn = yourButton.GetComponent<Button>();
        btn.onClick.AddListener(TaskOnClick);
    }


    void TaskOnClick()
    {
        if (paused)
        {
            Time.timeScale = 0;
        }

        if (!paused)
        {
            Time.timeScale = 1;
        }

        paused = !paused;
        myMove.enabled = true;
        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Locked;
        UiItem.SetActive(false);
        Item.SetActive(true);
    }


}

And here is the error message I get.

CONSOLE : Assets\Script\InventoryFlashLight.cs(10,12): error CS0246: The type or namespace name ‘Button’ could not be found (are you missing a using directive or an assembly reference?)

Would like some help thank you!

Looks like you forgot to say “using UnityEngine.UI;”

You know… I feel dump now… Thanks man!