Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Instance.new not creating Teams?

For some reason when I try and create a team it doesnt create it. I cant tell if its not parenting or just not creating it at all. Can anyone help?

local plrs = game.Players:GetChildren()
local redTeam = {}
local blueTeam = {}

local plrsOnEachTeam = math.floor(#plrs / 2)

function Team()
for i = 1, plrsOnEachTeam, 1 do
	local Team = game:GetService("Teams")
	local RedTeam = Instance.new("Team")
	RedTeam.Parent = Team
	RedTeam.TeamColor = BrickColor.new("Really red")
	RedTeam.Name = "Red"
	local Folder = Instance.new("Folder", RedTeam)
	Folder.Name = "leaderstats"
	local Hits = Instance.new("IntValue",Folder)
	Hits.Name = "Hits"
    table.insert(redTeam,#redTeam + 1,plrs[1])
    table.remove(plrs,1)
end

for i =1,plrsOnEachTeam,1 do
	local BlueTeam = Instance.new("Team")
	BlueTeam.Parent = Team
	BlueTeam.TeamColor = BrickColor.new("Navy blue")
	BlueTeam.Name = "Blue"
	local Folder = Instance.new("Folder", BlueTeam)
	Folder.Name = "leaderstats"
	local Hits = Instance.new("IntValue",Folder)
	Hits.Name = "Hits"
    table.insert(blueTeam,#blueTeam + 1,plrs[1])
    table.remove(plrs,1)
end
if #plrs == 1 then
    table.insert(redTeam,#redTeam + 1,plrs[1])
    table.remove(plrs,1)
end
end

1 comment

0

The BlueTeam parent is off on line 24 and are you running the function?

1 answer

listen i am no expert but when u parented the "RedTeam" i think you shoudve said Teams not "Team" maybe like this

local plrs = game.Players:GetChildren()
local redTeam = {}
local blueTeam = {}

local plrsOnEachTeam = math.floor(#plrs / 2)

function Team()
for i = 1, plrsOnEachTeam, 1 do
    local Team = game:GetService("Teams")
    local RedTeam = Instance.new("Team")
    RedTeam.Parent = game.Teams
    RedTeam.TeamColor = BrickColor.new("Really red")
    RedTeam.Name = "Red"
    local Folder = Instance.new("Folder", RedTeam)
    Folder.Name = "leaderstats"
    local Hits = Instance.new("IntValue",Folder)
    Hits.Name = "Hits"
    table.insert(redTeam,#redTeam + 1,plrs[1])
    table.remove(plrs,1)
end

for i =1,plrsOnEachTeam,1 do
    local BlueTeam = Instance.new("Team")
    BlueTeam.Parent = game.Teams
    BlueTeam.TeamColor = BrickColor.new("Navy blue")
    BlueTeam.Name = "Blue"
    local Folder = Instance.new("Folder", BlueTeam)
    Folder.Name = "leaderstats"
    local Hits = Instance.new("IntValue",Folder)
    Hits.Name = "Hits"
    table.insert(blueTeam,#blueTeam + 1,plrs[1])
    table.remove(plrs,1)
end
if #plrs == 1 then
    table.insert(redTeam,#redTeam + 1,plrs[1])
    table.remove(plrs,1)
end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.