I've made a tool to recover the value of an IntValue (HungerVal.Value). However, I need this tool to only be usable when the player's thirst and hunger IntValues are above 0. The below code still lets me use the tool when either of those IntValues equal 0, when it should instead be unusable while that condition is true.
local food = script.Parent local plr = game.Players.LocalPlayer local HungerVal = plr:WaitForChild("HungerVal") local ThirstVal = plr:WaitForChild("ThirstVal") local used = false food.Activated:connect(function() if HungerVal.Value and ThirstVal.Value > 0 then HungerVal.Value = HungerVal.Value + 40 used = true if HungerVal.Value > 100 then HungerVal.Value = 100 end food:Destroy() else print("I can't do that! I am unconcious!") end end)
The problem is that you are not checking HungerVal's Value. You are just checking if HungerVal.Value exist. so ofcource is gonna be true. So to fix this you would check both Values.
if HungerVal.Value > 0 and ThirstVal.Value > 0 then -- Code end