TeleportPartyAsync not working properly

local TeleportPlayers = {}
        
for _, Player in readyPlayers do
    table.insert(TeleportPlayers, Player)
end
        
local Success, Result = pcall(function()
    return TES:TeleportPartyAsync(Maps[math.random(1,#Maps)],TeleportPlayers)
end)

if Success then
    print("Players teleported to ", Result)
else
    warn(Result)
end

Warn returns with this Output, because of the TeleportPartyAsync - I’ve tried to handle the “TeleportPlayers” variable as an array and table. What’s up?

image

What does the variable Maps refer to? Take in mind the first parameter should be the place ID you want the players to teleport to.

2 Likes

Yes this is a map ID, I’ve printed it and it does print correctly as an ID. I’ve confirmed that it’s the TeleportPlayers variable that is in the ask here. I am using TeleportPartyAsync to make sure both players get in the exact same server.

1 Like
local TeleportService = game:GetService("TeleportService")

-- Function to teleport a player to a destination
local function teleportPlayer(player, destination)
    local success, errorMessage = pcall(function()
        TeleportService:Teleport(destination, player)
    end)

    if not success then
        warn("Teleportation failed: " .. errorMessage)
    end
end

-- Example: Teleport the entire party to a specific place
local function teleportParty(destination)
    local Players = game:GetService("Players")
    
    for _, player in pairs(Players:GetPlayers()) do
        teleportPlayer(player, destination)
    end
end

-- Example: Teleport the party to a specific place when a button is clicked
local button = script.Parent

button.MouseButton1Click:Connect(function()
    local destination = game.Workspace.TeleportDestination -- Replace with your destination
    teleportParty(destination)
end)

2 Likes

Yes this uses Teleport and not TeleportPartyAsync, this example also contains game.Workspace.TeleportDestination for no apparent reason, there are no place Id’s in Workspace.

1 Like

Have you tried printing the TeleportPlayers table? Make sure it is an array with only player objects, not names nor IDs.

1 Like

So thank you about that much test out

1 Like

I am not looking to use Teleport service is it does not reserve a server for 2 players to directly make sure they get in the same server. TeleportPartyAsync would make sure the players get in the same server, therefor my focus is directly on why this TeleportPartyAsync service is not working as intended.

I know that about when you add in the service

1 Like

image

This is how the TeleportPlayers variable prints as, it’s in the exact same format as Players:GetPlayers() which is used in Roblox’s documentation example.

I’m pretty sure these are strings, not player objects.

A player object wouldn’t have “”:
image

2 Likes

Try printing out that Maps[math.random(1,#Maps) to see what it returns. It should only be returning an number of the PlaceID and not a String. If it is a String, use tonumber() to convert it to a number.

1 Like

The table of Maps are without “”, and straight ID’s, prints in orange like a number.

1 Like

Oh shoot, this is probably the problem now yeah…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.