Help on odd lua error

So this guy from ukraine is getting a error:
[ERROR] …art_welding/lua/weapons/gmod_tool/stools/smartwelder.lua:273: attempt to index local ‘ent1’ (a nil value)

  1. unknown - …art_welding/lua/weapons/gmod_tool/stools/smartwelder.lua:273

It keep telling him its can be because he has over 100 addons on his server but he refuses to listen. That entire section of code is:

function TOOL:WeldEnts(ent1, ent2, bone1, bone2, weldstrength, smartnocollide, weldcount)

         if(ent1:IsValid() and ent2:IsValid()) then                                                           -- this is line 273
	         local const = constraint.Weld( ent1, ent2, bone1, bone2, weldstrength, smartnocollide )
			 undo.AddEntity( const )

			 if(((weldcount+1)%NOTIFYGAP)==0) then

			 		self:GetOwner():PrintMessage(HUD_PRINTCENTER,"Weld "..(weldcount+1).." placed")



The addon is smart weld. Could this error be because I screwed up fixing the addon for gmod 13. This is my first time scripting in lua so I’m not the greatest. So please help. Thanks

You’re calling the function without ent1 or ent2.
Add a check like

if ( ent1 and ent2 and IsValid(ent1) and IsValid(ent2) ) then

That will prevent the error.

Why is that though. Was it just because it change from gmod 12 to 13. Oh and thank you very much I really appreciate it ill try it out

[editline]23rd December 2012[/editline]

That made it worse. Now the tool doesn’t show