You have to import UnityEngine.UI by adding "using UnityEngine.UI" at the top of the script.
damn I didn't notice that, thanks man