"Unable to cast values to Objects" in Teleporter / GUI Script

Hello!
I’m trying to make a script that teleports the player to a different experience, but I keep getting this error: “Unable to cast values to Objects”

I’m not sure why this is happening, and whether it is related to changing the GUI or the Teleporting Service.

The other posts with a similar topic were related to using :TeleportToPrivateServer and teleporting parties, but I couldn’t find any information about :TeleportAsync

Here’s the script:

script.Parent.MouseClick:Connect(function(Player)
	local TS = game:GetService("TeleportService")
	TS:TeleportAsync(12777737748, game.Players[Player.Name])
	game.Players[Player.Name].PlayerGui.ArtInfo.Frame.dateOfCreation.Text = "Arriving soon!"
	game.Players[Player.Name].PlayerGui.ArtInfo.Frame.description.Text = "We hope to see you back at The Art Museum!"
	game.Players[Player.Name].PlayerGui.ArtInfo.Frame.Title.Text = "Teleporting to the AOS Museum"
end)

More information:
Target Experience: Atmospheric and Oceanic Sciences Museum - Roblox
Teleporting From: The Art Museum - Roblox

the second argument in TeleportAsync is a table of players not 1 singular player,
also you dont need to do game.Players[Player.Name] in every line because MouseClick passes the player that clicked it.

script.Parent.MouseClick:Connect(function(Player)
	local TS = game:GetService("TeleportService")
	TS:TeleportAsync(12777737748, {Player})
	Player.PlayerGui.ArtInfo.Frame.dateOfCreation.Text = "Arriving soon!"
	Player.PlayerGui.ArtInfo.Frame.description.Text = "We hope to see you back at The Art Museum!"
	Player.PlayerGui.ArtInfo.Frame.Title.Text = "Teleporting to the AOS Museum"
end)

Thank you, this worked for me!

1 Like

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