Help making a reverse of this invis script

Still learning…someone helped me with creating this:


local function InvisibleThink()
	for k, v in pairs(player.GetAll()) do
		local ActiveWeapon = v:GetActiveWeapon()
		if v.Invisible and IsValid(ActiveWeapon) and ActiveWeapon ~= v.CloakedWeapon then
			v.CloakedWeapon = ActiveWeapon
			ActiveWeapon:SetNoDraw(true)

			if ActiveWeapon:GetClass() == "weapon_physgun" then
				for a, b in pairs(ents.FindByClass("physgun_beam")) do
					if b:GetParent() == v then
						b:SetNoDraw(true)
					end
				end
			end
		end
	end
end
hook.Add("Think", "InvisiblePlayer", InvisibleThink)

function InvisiblePlayer(ply, invis)
	ply.Invisible = invis
	ply:SetNoDraw(invis)

	for k, v in pairs(ply:GetWeapons()) do
		v:SetNoDraw(invis)
	end

	for k,v in pairs(ents.FindByClass("physgun_beam")) do
		if v:GetParent() == target then
			v:SetNoDraw(invis)
		end
	end

	if not invis then
		ply.CloakedWeapon = nil
	end
end
concommand.Add ("hidemenow", InvisiblePlayer)

sta

What is the most effective way to make a function that undoes this. Do I need to make a brand new function and reverse everything. (which is probably beyond me, simply because there are a lot of variables switching back and forth here and I’d have to get them all right…I’d prefer to not have to spend more hours staring blankly at this but I want to at least get started on the right path…

If you want to make them visible again, just set invis to true.

Where is target being defined?

Could you help me with the syntax and placement on that? Would this actually work? Seems too simple…



function ReAppear(ply) 
          ply.SetNoDraw = false 

end 

I keep getting nil errors on ply being local. I’ve tried running a loop with no luck.

You already have a function there that takes invis as an argument. If you want it as a command, just create a new function and from within that function call InvisiblePlayer( ply, true )


 
function ReAppear()
InvisiblePlayer( ply, true )
end


I still get ply local nil error with this…

That’s because ply is not a defined variable.