How to put player in a solo team

Hello amazing peoples, so i am making a script so that when the round start every player will get a team they will be solo but the problem is that i am confused on how to make it here is my script so far:

local players = game:GetService("Players")
local timer = 25
local teams = game:GetService("Teams")
local value = game.ReplicatedStorage.Status
local inRound = game.ReplicatedStorage.InRound
repeat wait() until #players:GetPlayers() >= 4

inRound.Changed:connect(function()
	if inRound.Value == true then
		for _, players in pairs(game.Players:GetChildren()) do
			local char = players.Character
			for i = #teams:GetChildren(), 8, 1 do
				if players.Team == teams["Lobby"] then    ----kinda confuse on how to put player one in a team and the other one in a diffrent team 
                    players.Team = teams[i]
				end
			end
		end
	end
end)


local function roundTimer()
	for i = timer,1,-1 do
		value.Value = "Intermission "..i.." Seconds left"
		wait(1)
	end
	value.Value = "Game Started"
	inRound.Value = true
end

spawn(roundTimer)

what i want if you too is confused is that, Players will get different team they must be solo in their team i dont want it so that there is two or more player in a team i want all team to have only one person
there is a maximum of 8 teams any help is appreciated

Actually i solved it myself
i just need to make a table so when player got into a team there will be a team that is inserted in a table and if another player join a team it will check if the team is not in the table then it will proceed
if u wanna know how the script is here:

local players = game:GetService("Players")
local timer = 15
local teams = game:GetService("Teams")
local value = game.ReplicatedStorage.Status
local teamed = {}
local inRound = game.ReplicatedStorage.InRound
repeat wait() until #players:GetPlayers() >= 4

inRound.Changed:connect(function()
	if inRound.Value == true then
		for _, players in pairs(game.Players:GetChildren()) do
			local char = players.Character
			char.HumanoidRootPart.CFrame = CFrame.new(0,0,0) 
			for i,v in pairs(teams:GetChildren()) do
				if players.Team == teams["Lobby"] and not teamed[i] then
					players.Team = v
					local c = players.Team
					table.insert(teamed,c)
				end
			end
		end
	end
end)


local function roundTimer()
	for i = timer,0,-1 do
		value.Value = "Intermission "..i.." Seconds left"
		wait(1)
	end
	value.Value = "Game Started"
	inRound.Value = true
end

spawn(roundTimer)

Good job identifing the problem yourself!

1 Like