Hunger system sometimes error

while true do
	wait(10)
	for i, player in pairs(game.Players:GetChildren()) do
		local Hunger = player.NonPvPStats.Hunger
		local Character = player.Character
		local Human = Character.Humanoid
		
		local Sprint = Character.Sprint
		
		if Hunger.Value <= 0 then
			Character.Health.Disabled = true
			Sprint.Disabled = true
			Human.Health = Human.Health - 5
			wait(2)
		elseif Hunger.Value > 0 then
			Character.Health.Disabled = false
			Sprint.Disabled = false
			Hunger.Value = Hunger.Value - 2
			wait(2)
		end
	end
end
 ServerScriptService.Hunger:6: attempt to index nil with 'Humanoid' 

i am thinking of adding waitforchild but that would just inf yield

Don’t be use :GetChildren(), use :GetPlayers() instead.

Also, this should be in #help-and-feedback:scripting-support. #help-and-feedback:code-review is for reviewing working codes.

o mb i thought there was lil to no diffrence

:GetPlayers() makes sure it only gets all of the children’s which are actual players.