Ok so this script is a local script within a tool, aka an apple. This works perfectly fine with my hunger and thirst, and it has 3 uses. The one problem is if the player drops the tool then the amounts of uses gets reset back to 3. With this logic, the apple can be used an unlimited amount of time and is useless. How can I make this script retain the amount of uses in the tool even though it gets dropped by the player?
local tool = script.Parent
local player = game.Players.LocalPlayer
local HungerValue = player:WaitForChild("stats").Hunger
local ThirstValue = player:WaitForChild("stats").Thirst
amount = 3
tool.Activated:Connect(function()
amount = amount - 1
wait(2)
ThirstValue.Value = ThirstValue.Value + 20
HungerValue.Value = HungerValue.Value + 30
player.Character.Humanoid.Health = player.Character.Humanoid.Health + 2.5
if HungerValue.Value > 100 then
HungerValue.Value = 100
end
if ThirstValue.Value > 100 then
ThirstValue.Value = 100
end
if amount == 0 then
tool:Destroy()
end
end)
Example: The player takes two bites of the apple and drops it. Instead of only having 1 bite left, it gets reset back to 3 and its super annoying.

1 comment
Thank you!