Inserting a table into a table?

Alright, I have a table that’s supposedly contains all the banned players on my server. Via a function, I want to be able to add table to that table. (Because for every ban I want to contain the steamid, length, and reason).

I tried this code:

function PA_Ban(steamid, time, reason)
	table.insert(PA_banned.players, {steamid})
	table.insert(PA_banned.players.steamid, {time})
	table.insert(PA_banned.players.steamid.time, {reason})

But on the line of

table.insert(PA_banned.players.steamid, {time})

it throwed this error:

bad argument #1 to 'insert' (table expected, got nil)

How to do this?

Also, table is declared like this:

PA_banned = {
		["players"] = {}

PA_banned = {}
PA_banned.players = {} – Creates a table inside the PA_banned table.
PA_banned.players.steamid = {} – Creates a table inside the PA_banned.players table.
PA_banned.players.time = {} = {}

table.insert(PA_banned.players.steamid, “STEAM_0_0”) – Inserts the table PA_banned.players.steamid with a string.
table.insert(PA_banned.players.time, “1 hour”)
table.insert(, “Gabe Newell”)

print(table.concat(PA_banned.players.steamid)) – Prints the table.

/* Output:
1 hour
Gabe Newell */

Quickly wrote this in my advanced lua run :eng101:

table.Add will merge two tables into one. But in your PA_Ban function your inserting a table into the PA_banned[“players”] table. I’m not sure what your trying to do actually…

Do you want PA_banned[“players”] to be a table full of ‘dictionaries’. So players contains a tables with keys: “steamid”, “time”, “reason” and the appropriate value corresponding to the key?

PA_banned["players"] = {
    {["steamid"] = "STEAM_", ["time"] = 0, ["reason"] = "being a fgt"},
    { ... } -- rinse and repeat

If so thats not what your code is doing.

I am trying to make it so whenever I ban someone. The table will look like this:

	1 = steamid = "STEAM_0:0"
		time	= 0
		reason	= "Test"

And the second time I will ban someone

	1 = steamid = "STEAM_0:0"
		time	= 0
		reason	= "Test"
	2 = steamid = "STEAM_0:12123131233"
		time	= 23
		reason	= "Test #2"

table.insert(PA_banned.players,{steamid = "STEAM_0:0", time = 0, reason = "Test"})

That got it!