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?
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.
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)
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.
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.
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.
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.