Max distance for weld toolgun?

How would I proceed in making a max distance restriction for the toolgun “weld” to weld to props together ?

I saw it on many flood servers and I am wondering how they made it

Max distance between the two props that are about to be weld together?

Yeah exactly

Then, you should either create a custom tool based on the default Weld tool or use the hook

SANDBOX:CanTool and return false when the distance between the currently traced entity and the entity that you had chosen to weld something to before is greater than the max distance, notifying the player.
The code of the original Weld tool is: https://github.com/Facepunch/garrysmod/blob/master/garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/weld.lua

In the cantool hook you can run GetPos(1) on the players weapon and that should return the position of the first entity, then just compare the distance between that and the trace position the hook gives you and return false if it’s too far

How do I get the pos of the first and second entity?

I cant make sense of getting the pos of the players weapon

Same way as the tool itself stores it and does it.
You should take a look in this case at the Toolgun itself to see how it works.