Toggle default HUD using a ConVar

Hi, I’m new to Lua. Anyway, I’m trying to make a simple script that shows/hides the default Gmod HUD using a ConVar.

So far, I have this:


hhshow = CreateClientConVar("hh_show", "1", true)
function hh(name)
	res = hhshow:GetBool()
	for k,v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"}) do
		if name == v then
			return res
		end
	end
	return true
end
hook.Add("HUDShouldDraw", "hide hud script", hh)


There’s a problem with this script. The default HUD stays visible no matter what the ConVar (hh_show) is set to.

Can you please help me? Thank you.