Unable to cast value to object

I know there’s been plenty of similar posts on this exact error code, but none of them have been able to help me solve this issue. I’m trying to teleport players, but upon teleporting I get a warning from my teleportModule stating “Unable to cast value to object”.

Code here:

	local playersToTeleport = {}
	--
	for i, v in pairs(queue:GetChildren()) do
		local plr = v.Value
		local char = plr.Character
		local hum = char.Humanoid
		--
		if hum.Health > 0 then
			playersToTeleport[i] = plr.Name
		else
			v:Destroy()
		end
	end
	print(playersToTeleport)
	--
	local tpOptions = Instance.new("TeleportOptions")
	tpOptions.ShouldReserveServer = true
	--
	local teleportData = {
		TeleportedPlayers = playersToTeleport
	}
	tpOptions:SetTeleportData(teleportData)
	local success = teleportModule(placeIdToTeleport, playersToTeleport, tpOptions) -- Unable to cast value to object

I believe I might have just found the issue actually. I didn’t realize I was passing the playersToTeleport table as the players argument for :TeleportAsync

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