How to make a infinite health script

It is because you reference the player’s health outside of the part where it is actually changed. This is what I have noticed in my time scripting:

local health = humanoid.Health
health = 50

Well, why wouldn’t this work? Here is why:
The player has their own health. This is a number in the humanoid. When you say humanoid.Health like that, you are just simply getting whatever number the health is at. It doesn’t actually reference the property. You also need to change the max health first if you are going to do this by the way.

Here is the correct code:

Event.OnServerEvent:Connect(function(player,Health,Hunger,PlrToChange)
	local CurrentPlayer = game.Players:WaitForChild(PlrToChange)
	local Plrstats = CurrentPlayer:WaitForChild("PlayerValues")
	local HungerVal = Plrstats.Hunger
	local plrchar = CurrentPlayer.Character or CurrentPlayer.CharacterAdded:wait()
	local Humanoid = plrchar:WaitForChild("Humanoid")
	
	
	if Hunger == "inf" then
		HungerVal.Value = math.huge
		
	else
		HungerVal.Value = Hunger
	end
	
	
	if Health == "inf" then
        Humanoid.MaxHealth = math.huge
		Humanoid.Health = math.huge

	else
		
	end
	
end)

A slight issue I have had in the past with setting health to math.huge is that it doesn’t always work. This is why I recommend an invisible force field. Force fields are more reliable + they protect against explosions breaking joints too.