im trying to make a eating and drinking code but i dont know why its not working

so my code does fill the sliders necessary the only problem is that you can press e on literally anything you want and it’ll still replenish the food or water but it should only be doing this if the object is tagged as seen in my script. the GUI also doesn’t show up at all.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class foodanddrink : MonoBehaviour {
bool guiShow = false;
public GameObject meat;
public GameObject drinkablewater;
public int rayLength = 2;

public Slider hungerslider;
public int meatgain;
public Slider thirstslider;
public int watergain;

// Update is called once per frame
void Update ()
{//  eating
    
    RaycastHit hit;
    Vector3 fwd = transform.TransformDirection(Vector3.forward);
    if (Physics.Raycast(transform.position, fwd, out hit, rayLength))
    {
        if (hit.collider.gameObject.tag == "meat")
        {
            guiShow = true;
        }
        { 
            if (Input.GetKeyDown("e"))
            {
                hungerslider.value += meatgain;
                guiShow = false;
            }
        }
    }
}
// drinking
void update()
{
    RaycastHit hit;
    Vector3 fwd = transform.TransformDirection(Vector3.forward);
    if (Physics.Raycast(transform.position, fwd, out hit, rayLength))
    {
        if (hit.collider.gameObject.tag == "drinkablewater")
        {
            guiShow = true;
        }
        {
            if (Input.GetKeyDown("e"))
            {
                thirstslider.value += watergain;
                guiShow = false;
            }
        }
    }
}

void OnGUI()
{
    if (guiShow == true)
    {
        GUI.Box(new Rect(Screen.width / 2, Screen.height / 2, 100, 25), "Eat");
    }
}

}

Looks like you put a bracket in the wrong place.
The way you have it set up you only want to check if you are pressing e if there is meat in front of him.

 if (Physics.Raycast(transform.position, fwd, out hit, rayLength))
 {
     if (hit.collider.gameObject.tag == "meat")
     {
         guiShow = true;
         if (Input.GetKeyDown("e"))
         {
             hungerslider.value += meatgain;
             guiShow = false;
         }
     }
 }

But I would suggest switching the order of these checks so that you only shoot a ray in a press of e, then check if it hits meat. Shooting a ray every frame seems like a waste.

May i ask why you have 2 update Functions being called? and one being a non uppercase ‘U’, but either way from my understanding this will not work…
as much as i hate handing out code i have refurbished your code below, you may have to make some minor tweaks to suit the rest of the things in your game, but from my understanding this should work.

    using UnityEngine; 
    using System.Collections; 
    using UnityEngine.UI;
    
    public class foodanddrink : MonoBehaviour { 
    bool guiShow = false; 
    public GameObject meat; 
    public GameObject drinkablewater; 
    public int rayLength = 2;
    public Slider hungerslider;
    public int meatgain;
    public Slider thirstslider;
    public int watergain;
         
         void Update ()
         {
             RaycastHit hit;
             Vector3 fwd = transform.TransformDirection(Vector3.forward);
             if (Physics.Raycast(transform.position, fwd, out hit, rayLength))
             {
//Eat
                 if (hit.collider.gameObject.tag == "meat")
                 {
                     guiShow = true;
                     if (Input.GetKeyDown("e"))
                     {
                         hungerslider.value += meatgain;
                         guiShow = false;
                     }
                 }
//Drink
                 else if (hit.collider.gameObject.tag == "drinkablewater")
                 {
                     guiShow = true;
                     if (Input.GetKeyDown("e"))
                     {
                         thirstslider.value += watergain;
                         guiShow = false;
                     }
                 }
             }

         void OnGUI()
         {
             if (guiShow == true)
             {
                 GUI.Box(new Rect(Screen.width / 2, Screen.height / 2, 100, 25), "Eat");
             }
         }

But as stated by others you really want to minimise the usage of anything called in an update function, try and think of it like this…
okay so Update() is updating once per every frame…
the game runs at a standard of 60 frames per second… so your piece of code is being asked for a hit collision of meat or drinkablewater 60 times per second. in 1 minute that function is being called 3600 times…
very very wasteful of computer recourses just to see if your character is looking at meat or drinkable water. Just something to keep in mind, I hope i have helped you with what you were having trouble with.