Roblox Health Regen not working

In that case the server should be handling everything from monitoring hunger to dealing damage. No remotes necessary.

1 Like

So I would do this like this?

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Char)
		local GUI = Player.PlayerGui.Bars
		local Humanoid = Char:WaitForChild("Humanoid")
		local HungerFrame = GUI:WaitForChild("Hunger")
		local DotHunger = HungerFrame.DotHunger
		local Circle = HungerFrame:WaitForChild("Circle")
		local HungerShow = HungerFrame.HungerShow
		local MaxHunger = 100
		local HungerValue = Player:WaitForChild("HungerValue")
		local HungerColor
		local HungerChange
		
		HungerValue:GetPropertyChangedSignal("Value"):Connect(function()
			HungerColor = Color3.fromRGB(218, 133, 65):Lerp(Color3.fromRGB(13, 105, 172), HungerValue.Value/MaxHunger)
			HungerChange = HungerValue.Value/MaxHunger

			DotHunger:TweenSize(UDim2.new(HungerChange, 0, 1, 0), "In", "Quad", 1)
			DotHunger.BackgroundColor3 = HungerColor

			HungerShow.Text = HungerValue.Value.."/"..MaxHunger
			Circle.ImageColor3 = HungerColor
		end)

		while wait(3) do
			if HungerValue.Value >= 1 then
				HungerValue.Value = HungerValue.Value - 1
			end

			if HungerValue.Value == 0 then
				repeat wait(1)
					Humanoid.Health = Humanoid.Health - 5
				until Humanoid.Health == 0 or HungerValue.Value > 0
			end
		end
	end)
end)