***** = nil dont work

I have something like this:

local match = {
“12345678910” = { – Here = nil works and it will be deleted
“1324” – Here = nil dont works and it will be not deleted
},
“10987654321” = { – Here = nil works and it will be deleted
“2413” – Here = nil dont works and it will be not deleted
}
}

Im using match[tostring(player.UserId)] = nil but in some cases this dont works.
Could somoene explain why?

Could you please send a formatted version + elaborate a bit, the post isn’t very clear.

local match = {}


match[tostring(player.UserId)] = {}

		match[tostring(player.UserId)] = nil	

This Works


			table.insert(match[tostring(playerWhoCreatedMatchId)], tostring(player.UserId))

match[tostring(playerWhoCreatedMatchId)][tostring(player.UserId)] = nil

This dont works


1 Like

First argument in table.insert has to be the table itself.
Make sure gameMatches[tostring(playerWhoCreatedMatchId)] is indeed a table.

I also don’t see here gameMatches table, please show it.
I only see match.

I wrote gamematches wrong, i corrected it now.

1 Like

Try this:

table.insert(match, tostring(player.UserId))

This would insert the player’s user ID inside the match table.
[If I understood you right]

Doing so,
the player’s ID becomes a Key and {} becomes its value, meaning, match will become a dictionary now. So be careful not to be confused with arrays

The User id is correct inside, my Problem is when i want to nil it, the Player in the Player will not delete

What is Player, is that a value? Mind showing relevant screenshots

There are Player.UserId ´s inside the Player.UserId and i want to delete one of the Player.UserIds from the Player.UserId

I mean one guy creates a Game and his UserId is in the Table and if People want to join him their UserIds will be inside the UserId who created the Game.
If the Player Who Joined the Guy, who created the Match is leaving, the UserId inside the UserId will delete. I tryed it with = nil but it dont worked its just worked if i nil the UserId from the Guy who Created the Match.

So

match[tostring(player.UserId)] = nil | Works

but

match[playerWhoCreatedMatchUserId][tostring(player.UserId)] = nil | Dont works