Need help with Build Armor lua

this is what i have so far. what im trying to do is make it so if the player has out a physgun or toolgun they get godmode, and i tried putting my code into the SpawnSafe addon, i failed. Help please

AddCSLuaFile( “cl_SpawnSafe.lua” )
function ssAFK( ply, cmd, args )
if ply.lastAFK > CurTime() then
return
else
ply.lastAFK = CurTime()+2
end
if #args < 1 then ply.IsAFK = not ply.IsAFK
print(": noargs")

else
print(": args = "…tostring(args[1]))
local toggle=nil

if string.lower( args[1] ) == "true" then
	toggle = true
elseif string.lower( args[1] ) == "false" then
	toggle = false
else
	return
end

if ply.IsAFK == toggle then return end

if toggle != nil then ply.IsAFK = toggle print(": toggle: "..tostring(toggle)) end

end

if ply.IsAFK == true then
	ply:SetColor(0,0,0,255)
	ply:GodEnable()
            ply:PrintMessage( HUD_PRINTTALK, "You Now Have Build Armor God Mode." )
else
	ply:SetColor(255,255,255,255)
	ply:GodDisable()
            ply:PrintMessage( HUD_PRINTTALK, "You Now Have Lost Your Build Armor God Mode." )
end
print(": Iteration")

end
concommand.Add(“ssAFK”,ssAFK)
local function WeaponEquip( wep )

if wep:GetClass() == "weapon_physgun" || "gmod_toolgun" then
	ply:SetColor(0,0,0,255)
            ply:GodEnable
            ply:PrintMessage( HUD_PRINTTALK, "You Now Have Build Armor God Mode." )
    else
            ply:SetColor(255,255,255,255)
            ply:GodDisable()
            ply:PrintMessage( HUD_PRINTTALK, "You Now Have Lost Your Build Armor God Mode." )
end 

end

hook.Add( “WeaponEquip”, “Grabbin_Peelz”, WeaponEquip )

function ssInitSpawn( ply )
ply.lastAFK = CurTime()
ssAFK( ply, “”, {“true”} )
end
hook.Add( “PlayerInitialSpawn”, “ssInitSpawn”, ssInitSpawn )

function ssSpawn( ply )
ssAFK( ply, “”, {“true”} )
end
hook.Add( “PlayerSpawn”, “ssSpawn”, ssSpawn )

/function ssPlyMove( ply, data )
if ply.IsAFK == true then ssAFK( ply, “”, {“false”} ) else return end
end
/

function ssPlyKey( ply, key )
if ply.IsAFK == true then
ssAFK( ply, “”, {“false”} )
else return end
end
hook.Add( “KeyPress”, “ssPlyKey”, ssPlyKey )

Lua tags.

[lua]

function physgungodmode( )
for k,v in pairs(player.GetAll()) do

if v:GetActiveWeapon():IsValid() 
        && v:GetActiveWeapon():GetClass() == "gmod_tool" then
            v:GodEnable()
elseif v:GetActiveWeapon():IsValid() 
        && v:GetActiveWeapon():GetClass() == "weapon_physgun" then -- not really sure wth it's called
            v:GodEnable()
else v:GodDisable()
                end
        end
end

hook.Add(“Think”, “GodOnGunhold”, physgungodmode)

[/lua]

untested and probably won’t work for shit , but try it out anyways…

i will try it out thanks

it works, oh and btw im really new, how do u add lua tags?

Wrap the code, in the BBCode tags
[noparse][lua]//code here[/lua][/noparse]

Glad I could be of assistance , I still don’t see why I got rated dumb lol.

also do u know the code for like allowing noclip? is it like…
pl:NoclipEnable()
or v:NoclipEnable()

i cant find it

ply:SetMoveType(MOVETYPE_NOCLIP) --Turn noclip on
ply:SetMoveType(MOVETYPE_WALK) --Turn noclip off

that didn’t work for me(noclip thing)

If you tried using the noclip code in that code up above, you need to change “ply” to “v”.