Hey, so I'm making a game and at the beginning, once there are at least two players in the server, I want the server to pick two random players, both from the Free Agents team, put each one on a team, and make them the team captains for their respective teams. Here is my script so far... The first part works great but the part after "end" is the part that should be choosing the team captains and putting them on the teams "Home Team" and "Away Team" but it isn't working. It doesn't do anything, the players all stay on the "Free Agents" team and no one is made captain. Does anyone know what's wrong with this?
local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("2orMoreNeeded")
local team1 = game.Teams["Home Team"]
local team2 = game.Teams["Away Team"]
local FreeAgents = game.Teams:WaitForChild("Free Agents"):GetPlayers()
while game.Players.NumPlayers < 2 do -- how many players needed for the game to start.
status.Value = "Flag on the play! At least 2 players are required to begin!"
repeat wait(2) until game.Players.NumPlayers >= 2 -- how many players are in the game.
status.Value = "Picking Team Captains"
end
local HomeCap = FreeAgents[math.random(#FreeAgents)]
HomeCap.Team = game.Teams["Home Team"]
local AwayCap = FreeAgents[math.random(#FreeAgents)]
AwayCap.Team = game.Teams["Away Team"]
Thanks, Skyraider5

2 comments
table.insert isnt capitalized
it didn't work, the "Picking Team Captains" thing appears and then nothing happens, any idea why?