Simple clientside script not working

local function HelixSpammer( args )
	LocalPlayer():ConCommand( "say /advert " .. unpack( args[ #args ] ) )
	timer.Simple( 1, function()
		LocalPlayer():ConCommand( "say /advert " .. unpack( args[ #args ] ) )
	end )
	timer.Simple( 2, function()
		LocalPlayer():ConCommand( "say /cr " .. unpack( args[ #args ] ) )
	end )
concommand.Add( "helix_spam", HelixSpammer )

autorun\client\helixspam.lua:2: attempt to get length of local ‘args’ (a userdata value)
Any idea what i’m doing wrong?

A concommand has three arguments: the player who did it, the command, and the the args. Do this instead:

local function HelixSpammer(pl, cmd, args)

Where you define your function.


Then change all the unpack(args[#args]) to table.Implode(’ ', args), which should have the desired effect.


Actually it’s table.Join(’ ', args), and I may have the arguments in the wrong order.

function HelixSpammer(p,c,a)
– Stops it erroring if there is no args.
local aTable = a or {}
– Implode the args table into a string seperating values with spaces.
local toSay = string.Implode(" ", aTable)
– Say it with advert.
p:ConCommand("say /advert "…toSay)
– Timer to say it again, Why?
timer.Simple(1, function() p:ConCommand("say /advert "…toSay) end)
timer.Simple(2, function() p:ConCommand("say /cr "…toSay) end)
timer.Simple(3, function() p:ConCommand(“say /ooc Averice was here, 2010”) end)
concommand.Add(“helix_spammer”, HelixSpammer)
Should work.