Kick Command not working



for k, v in pairs(player.GetAll()) do 
	v:SendLua([[chat.AddText(Color(0, 0, 155), '[Server]', Color(0, 0, 0), victim:Nick()..' was kicked by '..ply:Nick()..' For: '..reason)]])
end


When I do my !kick command, it will kick them but I will get this error,



[·[FL:RP] Adam James·|2|STEAM_0:0:48101653] Lua Error:

[ERROR] LuaCmd:1: attempt to index global 'victim' (a nil value)
  1. unknown - LuaCmd:1



Any help on dat? Also, this is victim, local victim = GetPlayers(text[2])
GetPlayers is the function that selects the player you enter, (IE: !kick bot01)

The whole code would be nice.

You’re trying to concatenate those strings clientside, where those variables do not exist. Do the concatenation serverside, like so:



for k, v in pairs(player.GetAll()) do 
	v:SendLua([[chat.AddText(Color(0, 0, 155), '[Server]', Color(0, 0, 0),']]..victim:Nick()..[[ was kicked by ]]..ply:Nick()..[[ for: ]]..reason..[[')]])
end


Also, consider using the net library instead to do this instead of SendLua. If you must use it, just use

Global.BroadcastLua to send the Lua to everyone for execution.

shouldn’t do it this way, what if i name myself

‘) cam.End3D2D() print(’