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)