Argument 1 missing or nil

Hello developers,
So i encountered this error where it cannot pass through a for i loop. Im not so sure why but it looks like it only lets 1 person through and then breaks with this error message:

local TS = game:GetService("TeleportService")
local TweenService = game:GetService("TweenService")
local placeId = "11235153047" -- Enter a second Id Place.
local leaveGuiEvent = game.ReplicatedStorage.LeaveGuiEvent
local TransitionEvent = game.ReplicatedStorage.TransitionEvent
local list = {}
local billboard = script.Parent.billboardPart.billboardGui
local timer
local teleporting = false
local spawnTeleport = script.Parent.spawn

local maxplramt = script.Parent:WaitForChild("AmountOfPlayers")

local function updateGui()
	billboard.Frame.players.Text = "Players: " ..#list.. "/"..maxplramt.Value -- Change the number 16 according to the Max Player who want to be teleported.
end

local function removeFromList(character)
	for i=1,#list do
		if list[i] == character.Name then
			table.remove(list,i)
			updateGui()
		end
	end
end

updateGui()

local function teleportPlayers()
	if #list > 0 then
		teleporting = true
		local playersToTeleport = {}
		local teleportTime = 0
		local code = TS:ReserveServer(placeId)
		
		for i=1,#list do	
			if game.Players:findFirstChild(list[i]) then	
				table.insert(playersToTeleport,game.Players:findFirstChild(list[i]))
				
				local char = game.Players:findFirstChild(list[i]).Character
				local person = game.Players:findFirstChild(list[i])
				print(playersToTeleport)

				if char then
					char:MoveTo(game.Workspace.tptogameRoomPart.Position)
				end
				
				TransitionEvent:FireClient(game.Players:findFirstChild(list[i]))
				
				table.remove(list,i)
			else
				table.remove(list,i)	
			end
		end
		game.ReplicatedStorage.Events.TeleportToGame:Fire(playersToTeleport, code, placeId)
		teleporting = false
		updateGui()
		list = {}
		if maxplramt.Value > 1 then
			timer = 15
		else
			timer = 10
		end	
	end
end

script.Parent.Gate.Touched:Connect(function(hit)
	if hit.Parent:findFirstChild("Humanoid") then
		if teleporting == false then
			local char = hit.Parent
			local player = game.Players:FindFirstChild(char.Name)
			local alreadyExists = false
			
			for i=1,#list do
				if list[i] == char.Name then
					alreadyExists = true
				end
			end
			
			if alreadyExists == false then
				if #list < maxplramt.Value then -- Many Players have been teleported.
					table.insert(list,char.Name)
					char.PrimaryPart.CFrame = spawnTeleport.CFrame
					updateGui()
					leaveGuiEvent:FireClient(player)
				end
				
				player.CharacterRemoving:connect(function(character)
					removeFromList(character)
				end)
			end
			
		end
	end
end)

leaveGuiEvent.OnServerEvent:Connect(function(player)
	if player.Character then
		player.Character.HumanoidRootPart.Anchored = false
		wait()
		player.Character.Humanoid.Jump = true
		wait()
		player.Character:MoveTo(game.Workspace.leaveRoomPart.Position)
		removeFromList(player.Character)
	end
end)

while wait() do
	if maxplramt.Value > 1 then
		timer = 15
	else
		timer = 10
	end -- Wait time before teleport change to whawtever you want it to be
	for i=1,timer do
		timer = timer - 1
		billboard.Frame.time.Text = timer
		wait(1)
	end
	teleportPlayers()
end

I don’t know why list[i] is nil, but you can try this.

if list[i] and game.Players:FindFirstChild(list[i]) then

Yes it worked, its just some people dont get teleported and are left behind inside the teleporting room and my character didnt move to the tptogameRoomPart. It looks like it only teleports 2-3 max instead of 6

try changing it to for _, i in next, list do and change all list[i] to just i

I think it should be like

for _, i in list do

But I don’t know if there is a difference.