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

Instance.new not creating Teams?

Asked by 3 years ago

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
0
The BlueTeam parent is off on line 24 and are you running the function? Warfaresh0t 414 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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
Ad

Answer this question