Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

This team captains script STILL doesn't work? Does anyone know why it doesn't make anyone captains?

Asked by 5 years ago

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 still isn't working even with this new script that I was told would fix it. 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"]

while game.Players.NumPlayers < 1 do -- how many players you want 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 >= 1 -- how many players are in the game.
        status.Value = "Picking Team Captains"
        end
local teamname = "FreeAgents"
local freeagents = {} -- All the players on the freeagents team (Not set yet)

freeagents = {}
for a, b in pairs(game.Players:GetChildren()) do -- Getting all the childs on the ravens team
    if b.Team == teamname then -- Check if the players is on the wanted team
        table.Insert(freeagents,b) --Put him in the table
    end
end

local HomeCap = freeagents(math.random(1,#freeagents))
    HomeCap.Team = game.Teams["Home Team"]

freeagents = {}
for a, b in pairs(game.Players:GetChildren()) do -- Getting all the childs on the ravens team
    if b.Team == teamname then -- Check if the players is on the wanted team
        table.Insert(freeagents,b) --Put him in the table
     end
end

local AwayCap = freeagents(math.random(1,#freeagents))
AwayCap.Team = game.Teams["Away Team"]

I really need this to work so if anyone could tell me what's wrong with it I would really appreciate it. Thanks, Skyraider5

0
This is a duplicate post... greatneil80 2647 — 5y

Answer this question