local DECREASE_FREQUENCY = 1
local DECREASE_AMOUNT = 2
game.Players.PlayerAdded:Connect(function(Player)
local Hunger = Instance.new("IntValue", Player)
Hunger.Name = "Hunger"
Hunger.Value = 100 -- how much hunger a player has max
Player.CharacterAdded:Connect(function()
Hunger.Value = 100 -- resets each time your player respawns
game.StarterGui.Hunger.Bar.TextLabel.Text = (Hunger.Value)
end)
while wait(DECREASE_FREQUENCY) do
-- run the code in here.
if Hunger.Value <= 0 then
Player.Character:BreakJoints()
else
Hunger.Value -= DECREASE_AMOUNT
end
Hunger.Value -= DECREASE_FREQUENCY
end
game.StarterGui.Hunger.Bar.TextLabel.Text = (Hunger.Value)
At this point it should change to a new value as the hunger decreases, but it stays at the value 100? Could anyone explain to me what am doing wrong?