Help with hunger system

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Just a hunger system or smth

  2. What is the issue? The number value wont change (no errors popping up on the console)

  3. What solutions have you tried so far? i tried changing some variables

game.Players.PlayerAdded:Connect(function(plr)
	local char = plr.Character or plr.CharacterAdded:Wait()
	local hunger:NumberValue = plr:WaitForChild("Hunger")
	while task.wait(1) do
		if hunger.Value >= .1 then
			hunger.Value -= .1
		else
			char:WaitForChild("Humanoid").Health -= 5
		end
	end

	plr.CharacterAdded:Connect(function(chr)
		hunger.Value = 100
	end)
end)

HERES THE FIX

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local hunger : NumberValue = plr:WaitForChild("Hunger")
		while task.wait(1) do
			if hunger.Value > 0 then
				hunger.Value -= .1
			else -- if it is 0 then DAMAGE! 
				char:WaitForChild("Humanoid").Health -= 5
			end
		end

		hunger.Value = 100
	end)
end)
1 Like

it’s still not changing the value ;-;

Perhaps its a localscript? or something?

i just forgor to put the script in serverscriptservice lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.