Teleporting all players on different team to position

local team = game.Teams["team 1"]
local otherTeams = {};
table.insert(otherTeams, game.Teams["team 2"]);
table.insert(otherTeams, game.Teams["team 3"]);
table.insert(otherTeams, game.Teams["team 4"]);
table.insert(otherTeams, game.Teams["team 5"]);
table.insert(otherTeams, game.Teams["team 6"]);
table.insert(otherTeams, game.Teams["team 7"]);
table.insert(otherTeams, game.Teams["team 8"]);
script.Parent.Touched:Connect(function(hit)
    if hit.Name == "potatohitbox" then
        print("yes")
        hit.Parent:Destroy()
        workspace.potatoyesyes.Position = workspace.potatoyesgo1.Position
        workspace.potatoyesgo1.victoryroyale.EmitterSize = 1.5
        workspace.potatoyesgo1.victoryroyale.Playing = true
        local plrsOnTeam = team:GetPlayers()
        local plrsOnOtherTeam = otherTeams:GetPlayers()
        wait(2)
        for i, v in pairs(plrsOnTeam) do
            v.Character.HumanoidRootPart.Position = Vector3.new(89.6, 288.4, 392.5)
        end    
        for i, v in pairs(otherTeams) do
            v.Character.HumanoidRootPart.Position = Vector3.new(90.1, 280, 448.5)
        end     
    end
end)

the error is

attempt to call a nil value

line 18 where it says

local plrsOnOtherTeam = otherTeams:GetPlayers()

im basically trying to teleport the team to the winner section and the other team to the losers section

I don’t know much about tables, but you could try printing the otherTeams:GetPlayers().

From what I can see here, the script is trying to :GetPlayers() from an empty table. Try adding some sort of wait function.

like a wait(1) before the get players

You could do something like repeat wait() until #otherTeams ~= 0 at the top of the script.

But then again, I don’t know much about tables so I think it’s best to wait for other people who are more knowledgeable about tables.