I'm working on a story game, and right now I'm working on the lobby system, where the players join the lobby to get teleported and all that stuff. I have a GUI-based layout where you click buttons to get into each lobby (not physically walking into one like most other story games). My system is that each player is assigned a value in a dictionary, and the dictionary updates when players join or leave. However whenever I loop through the table to check an empty value to assign the player to, it doesn't seem to do that. No errors or anything, just...nothing.
Here is my code:
local players = {
Player1 = nil;
Player2 = nil;
Player3 = nil;
Player4 = nil;
Player5 = nil;
Player6 = nil;
Player7 = nil;
Player8 = nil;
}
game.ReplicatedStorage.Chapter1.AddToLobby.OnServerEvent:Connect(function(p)
print("nsdn")
for i, v in ipairs(players) do
print("yee")
wait()
end
end)
How do I fix this?

3 comments
well then how do i run through it in order?
so that a player doesn't get assigned spot 7 when spot 3 is vacant
nvm i think i got it.