How do i make an array of tables?

I’m attempting to make chatrooms for players, but I’m getting stuck on trying to place them into groups. I don’t know how I would go about it with arrays or literal replicated storage values. Can someone help me out?

The things below are functions to retrieve the next player of the list and grant ownership to them.

--The List itself:
local chatrooms = {
	UnnamedVoiceChat = 'OwnerName'
}

------------------------------------

local function frepossess(player, room)
	if chatrooms[room] == nil then
		error('oops')
	elseif player == nil then
		--This is where I should be retrieving the next player on the list or array.
		player.RoomOwnership.Value = room
		chatrooms[room] = player.Name
		repossess:FireAllClients(room, player)
	else
		
	end
end



You can put tables into tables no problem:

a = {}
a[1] = {}
a[1][1] = {}
2 Likes

Thank you I will try this! Is there any other way I can call another table without using a number? Perhaps in a situation where i search for a table by its name?

a = {}
a["Room 1"] = {}
a["Room 1"]["Players"] = {}
1 Like

After looking at @azqjanna’s script I found that putting tables into themselves was much simpler than I thought. The error I came across mainly was that Roblox does not consider these tables to be lists of values unless it has more than one value. So now with my new script you can check how many players are in the table.

In short I am now able to effeiciently sort and correct players with this function

Hopefully this can help someone else!

chatrooms = {
	UnnamedVoiceChat = {'VonickTW', 'Element2'}
}

local function newownership(player, room)
	local lotable = chatrooms[room]
	if #lotable > 0 then
		if #lotable > 1 then
			repossess:FireAllClients(room, player)
		end
	else
		print(room)
	end
end