TeleportPartyAsync - unable to cast value to Object

Hi all! I am attempting to write a script that teleports a group of people to a reserved server from a lobby. When testing this, everything runs smoothly until line 21, when the compiler says “Unable to cast value to Object”. This is the only error so far, any advice? (code below)

local teleport = game:GetService("TeleportService")
local players = game:GetService("Players")
local teams = game:GetService("Teams")
local event = game:GetService("ReplicatedStorage")
local gui = game:GetService("StarterGui")

function StartGame()
	print("fired start")
	if #teams.Queued:GetPlayers() > 0 then
		local countdown = gui.ScreenGui.Countdown
		event.CountdownVis:FireAllClients(true)
		for i=10,0,-1 do
			event.CountdownText:FireAllClients(i)
			wait(1)
		end
		if #teams.Queued:GetPlayers() > 0 then
			local PLACE_ID = --id--
			--local tpOptions = Instance.new("TeleportOptions")
            --tpOptions.ShouldReserveServer = true
			local players = {teams.Queued:GetPlayers()}
			teleport:TeleportPartyAsync(PLACE_ID, players)
            -- rest of function --

GetPlayers() already returns a table. So basically, what your line does is:

local players = {
	{
		Player1,
		Player2,
	} -- Extra table, not needed.
}

Just do local players = teams.Queued:GetPlayers()


edit: i accidentally replied too early

1 Like

Thank you very much! Works perfectly now.

1 Like

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