Hi I am trying to make a hunger and thirst system where your health goes down when the hunger value reaches 0. But I am not getting any errors and it is not working, any help would be greatly appreciated.
local decreaseFrequency = 2
local decreaseAmount = 30
game.Players.PlayerAdded:Connect(function(player)
local Thirst = Instance.new("IntValue", player)
Thirst.Name = "Thirst"
Thirst.Value = 100
local Hunger = Instance.new("IntValue", player)
Hunger.Name = "Hunger"
Hunger.Value = 100
player.CharacterAdded:Connect(function()
Hunger.Value = 100
Thirst.Value = 100
end)
while wait(decreaseFrequency)do
Hunger.Value -= decreaseAmount
Thirst.Value -= decreaseAmount
if Hunger.Value == 0 then
player.Humanoid.Health -= 2
end
end
end)