Removing hud in custom gamemode

Hey all,

Just started getting into lua and I’m not exactly sure how to remove the ugly hud from the gamemode,

I am deriving the gamemode off sandbox, and using the code below to attempt to remove the hud and it’s not working.

I’ve included it in files and, I dunno, it’s just not working, any help?

[lua]
function GM:HUDShouldDraw( name )
if ( name == “CHudHealth” or name == “CHudBattery” ) then
return false
end
return true
end
[/lua]

Probably not right, but that’s what gmod wiki told me to do.



function hidehud(name)
	for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"}) do
		if name == v then return false end
	end
end
hook.Add("HUDShouldDraw", "HideOurHud:D", hidehud)


Found here: https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4bb6.html

That’s not working either. It’s still showing that yellow health bar.


function hidehud(name) -- Removing the default HUD
	for k, v in pairs({"CHudHealth", "CHudBattery"})do
		if name == v then return false end
	end
end
hook.Add("HUDShouldDraw", "HideOurHud:D", hidehud)

Oh wait, nevermind it did work, I forgot to put include ( “cl_hud.lua” ) into cl_init whoops

THanks guys!