SO I am trying to make a hunger and thirst script, and the if statement where I see if the hunger and thirst is below 1 is not seeming to work. Can anybody look at it and see what my problem is. It is not giving me any errors in the output.
function onPlayerEnter(player)
local playername = player.Name
print(playername)
local humanoid = game.Workspace:FindFirstChild(playername)
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(0.1)
hunger.Value = hunger.Value - 1
thirst.Value = thirst.Value - 1
end
if hunger.Value < 1 or thirst.Value < 1 then -- Part that is not seeming to work
while true do
wait(1)
humanoid.Health = humanoid.Health - 1
end
end
end
game.Players.ChildAdded:connect(onPlayerEnter)

1 comment
This isn't a request.