Disabling hud on swep

Basically, there is a camouflage SWEP that I use for my darkrp server. It makes you go invisible, but the problem is, it still shows the hud above your head. Is there like a code I can add to the swep to make it not show that when using primary attack?

You said when you’re using primary attack, so

WEAPON/PrimaryAttack might help you.

It’s not the SWEP you gotta edit, it’s the HUD. ( If we are talking about custom HUD )

No, DarkRP naturally does that.

What you have to do in order to achieve this is to add a hook for HUDShouldDraw and check for the name “DarkRP_EntityDisplay”. This hook allows you to return a table of players that will have an entity display over them.

hook.Add( "HUDShouldDraw", "DarkRP_Camouflage_Hide", function( name )
	if name == "DarkRP_EntityDisplay" then
		local players = {} -- This can probably be optimized somewhat
		local i = 1

		for k, ply in pairs( player.GetAll() ) do -- Get all players and exclude those that are camouflaged
			if not IsValid( ply ) or ply == LocalPlayer() then continue end

			if not ply:GetNWBool( "DarkRP_Camouflaged" ) then -- Check if this player is camouflaged
				players[ i ] = ply

			i = i + 1 -- Increment index (this is slightly faster than using #players + 1)

		return true, players -- Return true to prevent any other hooks from running, and also return the player table
end )

I have not tested this code yet though so feel free to point out any mistakes I might have made, and any optimizations that can be made.
The SWEP has to set the “DarkRP_Camouflaged” NWBool on the player to true serverside when it is activated, and set it to false when it is not activated.