"Unable to cast Value to object" with TeleportAsync

Hello everyone, first time posting. I’m having trouble with sending Data via teleport. So I’ve tried using regular Teleport but I wasn’t able to send data. Using the Dev Help Forum, I’ve switched it to TeleportAsync and still having trouble.

Basically, what I’m trying to do is teleport back to my main place but with a true/false boolean. Its to confirm if they entered the battle or not. I do not want to use DataStores.

Thank you for your time

local teleportService = game:GetService(“TeleportService”)
local TeleportKeith = script.Parent
local Home = 7420543783
local db = true

TeleportKeith.Touched:connect(function(hit)
local char = hit.Parent
local hum = char:FindFirstChild(“Humanoid”)
local player = game.Players:GetPlayerFromCharacter(char)
local teleportOptions = Instance.new(“TeleportOptions”)
local telePortData = {KeithBattle = true, KingAxo = false}

if db and hum then
	local player = game.Players:FindFirstChild(char.Name)
	local pVars = player:WaitForChild("PlayerVars")

	db = false
	teleportOptions:SetTeleportData(telePortData)
	teleportService:TeleportAsync(Home, {player},telePortData)
	-- teleport back, send Data
end
wait(10)
db = true

end )

The 3rd parameter of TeleportAsync is TeleportOptions, not TeleportData.

1 Like

Thank you so much! Now to work on the receiving end