table.random question


local list2 = {
	"string1",
	"string2",
	"string3",
	"string4",
	"string5"
}
local weapon = ents.Create(table.Random(list2))
weapon:SetPos(self:GetPos())
weapon:Spawn()

How would I go about making the table.random result be stored in a variable as a string format?



local var = table.Random(table)


???

Im talking about getting the result from local weapon = ents.Create(table.Random(list2)) So I can put it then later in a sendlua where it says in the chat the result of that table.Random

You would store it before creating the weapon.

[lua]
local myVar_ = table.Random(list2)
local weapon = ents.Create(myVar_)

SendToPlayerRoutine(myVar_)
[/lua]

Also if I could just urge you not to use sendlua to network the result, but instead use the net library. In this case, if you are sending a static variable then it would be fine, but you don’t want to get into the habit because it’s very easy to accidentally open an exploit.

Thanks a lot, I’m using it now just to send a static variable since yes it’s very exploitable. Thanks again!