I am trying to get the hunger and thirst to regen after the character dies and this is the only method I can think of to make this work.
function onPlayerEnter(player)
local hunger = Instance.new("NumberValue") -- Creating the hunger value
hunger.Name = "Hunger"
hunger.Parent = player
hunger.Value = 100
local thirst = Instance.new("NumberValue") -- Creating the thirst value
thirst.Name = "Thirst"
thirst.Parent = player
thirst.Value = 100
while true do
wait(2)
hunger.Value = hunger.Value - 50
thirst.Value = thirst.Value - 50
if player.Character.Humanoid.Health <= 0 then -- Part that is not seeming to work. ):
print("Working")
wait(6)
hunger.Value = 100
thirst.Value = 100
end
while hunger.Value < 0 or thirst.Value < 0 do
wait(0.5)
player.Character.Humanoid.Health = player.Character.Humanoid.Health - 5
end
end
end
game.Players.ChildAdded:connect(onPlayerEnter)

3 comments
first of all, when you have two while loops in the same script, the seond one isn't going to do anything
well it does
Lol, yeah it would still work :P But I don't think that's the best way of doing it :P