Console command help and best way of transmitting data?

So I’ve recently taken up an old Gamemode I made an I’m currently re-writing it. I’m trying to make it so that when I run a console command on the client side it will set the players team on the server side. This in itself is simple and I’m currently doing this through ConCommands however, to make the code “better” I’m trying to pass args through the ConCommand (The arg being the ID of the team, see code below.) I’ve played around with the code however I always get some strange error like “Number expected, got string” and whenever I try to debug the code instead of printing the value I tried to pass through it prints a table?


RunConsoleCommand( "setTeam", 1 )
RunConsoleCommand( "playerloadclass" )


function setTeam( ply, cmdName, teamID )
	-- Put team balancing here
	print("TeamID Recieved",teamID)
	ply:SetTeam( teamID )
concommand.Add( "setTeam", setTeam )

I’ve also got a question about transferring data, if I wanted to run a function on server side/client side would it be better to create ConCommands or use a networking library?

Use the net library, not console commands.



You have teamID set to the args parameter so
ply:SetTeam( teamID[1] )

Check if the team exists and teamID[1] (args) is set too