How do I fix this error when teleporting players?

The script which is supposed to, when the player hits E, teleport them to another game.

local landteleport = script.Parent

landteleport.ProximityPrompt.Triggered:Connect(function(player)
		game:GetService("TeleportService"):Teleport(6505902385)
		print ("Teleporting Player!")
	end)```

The error says ''invalid player to teleport.'' Can I get some assistance? I appreciate it, thank you!

If this is a Server-Sided script, the Teleport function requires another parameter which is the “Target Player” to teleport:

local landteleport = script.Parent

landteleport.ProximityPrompt.Triggered:Connect(function(player)
		game:GetService("TeleportService"):Teleport(6505902385, player)
		print ("Teleporting Player!")
	end)
2 Likes

Thank you so much. I appreciate it.

1 Like

Yeah anytime! If it was on a LocalScript then that function would work just fine, otherwise the server would need to find the specific player that activated the Teleport function

Do look at the code samples from these as well:

1 Like