TeleportPartyAsync() only teleports one person?

Hello! I am kind of new to Lua and Roblox scripting and I am currently developing a game that requires a teleportation system however an error has stumped for quite a while now. I use the function TeleportPartyAsync() to teleport everyone that is listed in a table. However, when I tried to teleport two players into the server together, only one of them was teleported. I have repeated this multiple times but still, only one person was teleported. I am not sure if it has to do something with my code or with the settings of the game. Thank you in advance for your assistance:)

The code relating to the teleporting process:

 local area = script.Parent.Parent.area

function collectPlayers()
    local pos1,pos2 = (area.Position - (area.Size / 2)),(area.Position + (area.Size / 2))
    local region = Region3.new(pos1,pos2)
    local playersFound = game.Workspace:FindPartsInRegion3(region)
    local tplist = {}
	
	for _, v in pairs(playersFound) do
		local pl = v.Parent:FindFirstChild("Humanoid")
		if pl then
			local player = game.Players:GetPlayerFromCharacter(pl.Parent)
			if not table.find(tplist, player) then
				table.insert(tplist, player)
			end
		end
	end
	return tplist 
end

local TeleportService = game:GetService("TeleportService")
local gameID = [my game id is here]

function teleport() 
	local players = collectPlayers()
	TeleportService:TeleportPartyAsync(gameID, players)
	wait(6)
	for _, v in pairs(spawner) do
	    v.occupied.Value = false
		v.occupier.Value = ""
		countPlr:Fire()
	end
end

TeleportService.TeleportInitFailed:Connect(function()
	local players = collectPlayers()
	for _, v in pairs(players) do
		print("Teleportation process failed at Gate B")
		v.Character.HumanoidRootPart.CFrame = spawnpoint.CFrame
	end
end)

FindPartsInRegion3 has 4 parameters:

  1. Region
  2. Ignore Instance: the instance, as well as its descendants, that will not be detected in the region
  3. MaxParts: the maximum number of parts that can be returned from the function
  4. Ignore Water: Whether or not the region can ignore water

You might want to use the 2nd and 3rd parameter. You’d want to put parts inside the region that you don’t want to detect as the 2nd parameter. For the 3rd parameter, you can set it to math.huge. By default, maxParts is set to 20, which means only a maximum of 20 parts can be returned, which is probably why it can’t teleport other players. Here’s how the function should look like:

local playersFound = workspace:FindPartsInRegion3(region, ignoreModel, math.huge) 
1 Like

I never knew that there was a max on how many parts can be detected. Thank you very much for the help! I tried it just a minute ago and it finally worked:)