print() will print and entity by it’s self, but you can not concatenate an entity without tostring(), same with vectors, etc. I do it all the time to check what entity’s are getting passed to hooks. So how about everyone stop arguing about it.
] rcon lua_run print(ents.GetAll())
] rcon lua_run print("This is the world entity" .. ents.GetAll())
[@lua_run:1] bad argument #2 to ? (string expected, got Entity)
So Zencro, as far as what you are trying the best way I can think of to cut down on the number of welds is to pick one entity in the radius and weld everything else to that one, like this.
local entPos = Vector(0,0,0) – Whatever point you are looking for entities
local entsInSphere = ents.FindInSphere(entPos, 1000) – Use descriptive names even in testing, it helps
local rndEntNum = math.random(1,table.Count(entsInSphere)) – Pick a random ent to weld to
local weldEnt = entsInSphere[rndEntNum] – Now get the random ent
table.remove(entsInSphere, rndEntNum) – Take it out of the table so we don’t weld it to it self.
for k, ent in pairs(entsInSphere) do – Loop through the rest of the table you can use k,v but again descriptive is better.
constrain.Weld(weldEnt, ent, 0, 0, 0, true) – Weld every ent in the table to the one entity we picked
I wrote this in the browser window, but it should work. I hope the comments help.