Food Deletion After Eating

I have food and drink items in my game, I need them to disappear from your inventory after you use them, but whenever I use this script the food doesn’t fuel the bar. what should I do?

local tool = script.Parent
local plr = game:GetService("Players").LocalPlayer
local reloadTime = 1

tool.Enabled = true
 
tool.Equipped:connect(function(mouse)
	print("Tool equipped!")
	 
	mouse.Button1Down:connect(function()
		print("Mouse pressed!")
		
		if not tool.Enabled then
			return
		end

		tool.Enabled = false
				
		local x = plr.Character.HungVal.Value
		
		if x <100 then --if the thirst value is above 100 it will not do this (although if the value is at 99 and you tell it to add 10 it will for a litle while therefore be over 100)
			plr.Character.HungVal.Value = plr.Character.HungVal.Value + 5 --This is the amount your thirst value increaes when you drink
		end
				
		wait(reloadTime)
		
		tool.Enabled = true
		

	end)
end)

tool.Unequipped:connect(function(mouse)
	print("Tool Unequipped!")	
end)
1 Like

use Tool:Destroy() it completely removes it, and also read : Instance:Destroy()

3 Likes

did not work, what to do??

local tool = script.Parent
local plr = game:GetService("Players").LocalPlayer
local reloadTime = 1

tool.Enabled = true
 
tool.Equipped:connect(function(mouse)
	print("Tool equipped!")
	 
	mouse.Button1Down:connect(function()
		print("Mouse pressed!")
		
		if not tool.Enabled then
			return
		end

		tool.Enabled = false
				
		local x = plr.Character.HungVal.Value
		
		if x <100 then --if the thirst value is above 100 it will not do this (although if the value is at 99 and you tell it to add 10 it will for a litle while therefore be over 100)
			plr.Character.HungVal.Value = plr.Character.HungVal.Value + 10 --This is the amount your thirst value increaes when you drink
		end
				
		wait(reloadTime)
		
		tool.Enabled = true
		
		wait(1)
		
		tool:Destroy()
		

	end)
end)

tool.Unequipped:connect(function(mouse)
	print("Tool Unequipped!")	
end)

Does it give an error? because it should work

Is this a Local or Server script?