I am making a tool that is raw beef and I was gonna make it so after a certain amount of bites, the tool gets destroyed. I am destroying on the server, and I did connect with remotes. The tool does get destroyed, but after I unequip the tool
--Client
wait()
local yes = false
local tool = script.Parent
local bites = 0
local foodHandler = game:GetService('ReplicatedStorage'):WaitForChild('foodHandler')
local foodItem = tool.Name
tool.Activated:Connect(function()
if not yes then
yes = true
eatAnim:Play()
bites = bites + 1
print(bites)
wait(3)
if bites == 3 then
foodHandler:FireServer(foodItem)
end
yes = false
end
end)
--Server
local foodHandler = game:GetService('ReplicatedStorage'):WaitForChild('foodHandler')
local function removeFood(player, foodItem)
player.Backpack:WaitForChild(foodItem):Destroy()
end
foodHandler.OnServerEvent:Connect(removeFood)
everything else in the script works. If you can help me then tysm!

3 comments
instead of doing "if not yes then" have you tried doing "if yes == false then"?
if not checks if the value is false, if checks if its true
I think I have an Idea Maybe do I a IF Statement to Get the amount of Bites and After It reaches The Amount You Want Move the Tool To Server Storage