Why does it say "Unable to cast value to Object"?

So im making a lobby that teleports players into the actual game and when it reaches 0 and im in the queue it shows this:

Line 50 is the line after the for i,v in pairs loop for PassengerTable:

--Function Countdown
function countdown()
	timerLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
	
	CanEnter = true
	for i = 30, 0, -1 do
		timer.Value = i
		--Red Text
		if timer.Value < 10 then
			timerLabel.TextColor3 = Color3.fromRGB(255, 20, 60)
		end
		--Disables leaving
		if timer.Value < 3 then
			CanEnter = false
			for i,v in pairs(PassengerTable) do
				LeavePlane:FireClient(v)
			end
		end
		wait(1)
	end

	if passengers.Value == 0 then
		wait(1.5)
		countdown()
		CanEnter = true
	end
	
	timerLabel.Text = "Boarding Plane.."
	
	local reservedServer = TeleportService:ReserveServer(7936258099)
	
	for i, v in pairs(PassengerTable) do
		TeleportService:TeleportToPrivateServer(7936258099, reservedServer, v, passengers.Value)
	end

	table.clear(PassengerTable)
	countdown()
end
9 Likes

By “casting” it means it is trying to turn the input value to an object, and it errored trying to do so.

You don’t need to iterate over the PassengerTable to teleport them all to the same server. TeleportToPrivateServer's 3rd argument accepts an array of players.

TeleportService:TeleportToPrivateServer(7936258099, reservedServer, PassengerTable, passengers.Value)

23 Likes

Ohhhhh okay thanks i will try this

4 Likes