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 --