How to Use table.insert with this type of argument

First of all, I am sorry if this is a duplicate topic, this is because of my small brain (I dont know what this type of argument is)

local Teams = {
	
	Lobbies = {
		["LobbyName"] = teamName,
		["Owner"] = player.UserId
	}
	
}

I wanted to use table.insert on this type of argument above but I do not know how, I tried researching but Idk what that argument is called lol. Any help is appreciated

Is it not very hard

table.insert(Teams, {Lobbies = {["LobbyName"]= teamName, ["Owner"] = player.UserId}})
1 Like

Oh ye I didnt think about that :sweat_smile:, tnx about this but 1 more question, what’s the name of that argument

Your table is a dictionary, you shouldn’t use table.insert, it’ll make things complicated, you can instead do this

local Teams = {
	Lobbies = {
		["LobbyName"] = "sup",
		["Owner"] = 123
	}
}
print(Teams.Lobbies.LobbyName) -- This is going to print "sup"

Teams.Lobbies.Myself = "me" -- or Teams.Lobbies["Myself"] = "me"

print(Teams.Lobbies.Myself) -- This will print "me" because we inserted a new key -->
--> with a set value to the dictionary.

Or you could do this:

Teams["Lobbies"] = {["LobbyName"] = teamName, ["Owner"] = player.UserId}

This will also insert it in the table but in a different way. If you really want to use table.insert() which I don’t understand you would use it for this you can use the option I showed to you before. But I recommend this option Aspecturu explained it correctly.

Hmm I wanted to make a matchmaking system which makes uses “dictionaries” ye thank you for remind me man to store info about the system, by Making a new team I like to add a new table that leads me to my 2nd question, is how do I set a different name for each argument inserted since I would not like to be every array to be the same name since it will most likely cause issues. Tnx for the info btw

yep just like what I said above, the purpose of table.insert is for a matchmaking system

But table.insert() and inserting it in a different way is exactly the same right?

can you please clarify what you said, I didn’t quite understand :sweat_smile:

Edit: ok wait nvm, I understand now thanks and ye true

I would recommend using the way I and Aspecturu showed you.

yep that actually gave me a great idea by rereading ur message, tnx for all the help :smile: