local TeleportService = game:GetService("TeleportService")
local remoteEvent = game.ReplicatedStorage.Teleport
local function serverReceiveEvent(player)
local reserveCode = TeleportService:ReserveServer(game.PlaceId)
TeleportService:TeleportToPrivateServer(game.PlaceId, reserveCode, {player})
end
remoteEvent.OnServerEvent:Connect(serverReceiveEvent)
You cant use teleport service in studio. Doing it in the game will fix. Just add this before the line of you dont want the error:
local RunService = game:GetService("RunService")
local TeleportService = game:GetService("TeleportService")
local remoteEvent = game.ReplicatedStorage.Teleport
local function serverReceiveEvent(player)
if RunService:IsStudio() then warn("Cannot use teleport service in studio!") end
local reserveCode = TeleportService:ReserveServer(game.PlaceId)
TeleportService:TeleportToPrivateServer(game.PlaceId, reserveCode, {player})
end
remoteEvent.OnServerEvent:Connect(serverReceiveEvent)
Did you make the script to fire the remote event from a local script? For example, I had a button in a screen gui containing a local script with these contents:
local TeleportService = game:GetService("TeleportService")
local remoteEvent = game.ReplicatedStorage.Teleport
local function serverReceiveEvent(player)
local reserveCode = TeleportService:ReserveServer(game.PlaceId)
TeleportService:TeleportToPrivateServer(game.PlaceId, reserveCode, {player})
end
remoteEvent.OnServerEvent:Connect(serverReceiveEvent)
Then ensure you publish the changes, File Save To Roblox and File Publish To Roblox, then test in game.