How do I fill up the open slots as players join game

I have a team lobby that when players join, there added to slots;

local playerName = game.Players.LocalPlayer.Name

if playerName then
script.Parent.Text = playerName
end

but it just fills ever slot with the same players name, is there a way to just allow one slot per player and the next player that enters and if a slot available it continues to add until team is full which then it will start filling up the other team if isn’t full? Then once the teams are full or at least an even amount, then timer counts down for match start.

Is this for when players join the game or join a team?

Use a BoolValue:

local player = game.Players.LocalPlayer

if player then
    for i, v in ipairs(YOUR_SLOT_FOLDER_PATH)
        if (not v:FindFirstChild("Filled") then
             v.Text = player.Name
             local Filled = Instance.new("BoolValue")
             Filled.Value = true
             Filled.Parent = v
        end
    end
end

Not the best idea to handle teammaking in the client but tw’ill do 4 now.

well i have a main screen lobby that the player can interact with stuff but when they press the start game, it brings them to this lobby where they can pick a team to play on in the game, and once the teams are full or at least even, the match will start.

I added your script but still nothing is showing up…:thinking:, Im not getting errors i’m just not seeing the names fill in the TextLables.

Maybe add a value inside of the player declaring their team?

The script creates a BoolValue inside the button that is set to false by default, I’m guessing once the teams are full it will be set to true. But I’m not seeing the players name in the gui but I do see that if i check the Text box in properties it says my gamer tag name, so I know that its working, it’s just not being displayed on gui.