In the anonymous function, add player as an argument and then replace playToTeleport with player, as when a RemoteEvent gets fired it returns the Player who fired it and then the data sent if there is.
Or if you want all players to be teleported you can do a:
for _, Player in game:GetService("Players"):GetPlayers() do
teleport:TeleportAsync(PlaceID, Player)
end
It’s good practice to wrap network methods like this in a pcall. This can help you diagnose issues. Have you checked to make sure the server is receiving your event in the first place?
-- server script
local TeleportService = game:GetService("TeleportService")
local MyEvent = game:GetService("ReplicatedStorage"):WaitForChild("Teleport")
MyEvent.OnServerEvent:Connect(function(player)
print(player.Name, "wants to teleport!") -- simple debug print to make sure
-- we get the event call in the first place!
local result, msgOrTpResult = pcall(function()
return TeleportService:TeleportAsync(place_id, { player })
end)
if not result then
warn("TelportAsync failed:", msgOrTpResult)
end
end)
Look out for a warning that will state why your teleport failed, if your issue persists and you get a warning, please share it here. If you do not get teleported and no warnings are printed, ensure the event is getting fired by making sure you see a “[name] wants to teleport!” in the output.
If the place you are attempting to teleport to is not part of the same experience and not owned by the same person, you will need to enable third-party teleports. I know this was already mentioned, but you cannot teleport in studio!