Can't make private servers

I’m trying to make a private server button because when you join my game it’s actually a menu that has play button to teleport to a place where the actual game is, and I made the “Private Server” button for people to be able to grind in private server easily but when I teleport a person to the reserved server it somehow teleports them back to the public server and I don’t know why, here’s the code for teleporting the person:

prompt3.OnServerEvent:Connect(function(player)
	local reservedServer = tpservice:ReserveServer(17066404164)
	local loadingscreen = game:GetService("ServerStorage").TeleportGUI:Clone()
	tpservice:TeleportToPrivateServer(17066404164, reservedServer, {player}, nil, nil, loadingscreen)
end)
1 Like

On the documentation, it is recommended to use TeleportAsync instead of TeleportToPrivateServere for this scenario.

You can add teleportOptions to create a new reserved server without needing to create a new one.

Sample code:

local tpservice = game:GetService("TeleportService")
local ServerStorage = game:GetService("ServerStorage")
local prompt3 -- set this to wherever prompt3 is 

prompt3.OnServerEvent:Connect(function(player)
     local teleportOptions = Instance.new("TeleportOptions")
     
     -- Setting ShouldReserveServer to true will automatically create a ReservedServer and teleport the provided players to the server when TeleportAsync is called with the TeleportOptions
     teleportOptions.ShouldReserveServer = true 

    -- it is highly recommended that you add error handling with a pcall. 
-- For more info on handling failed teleport, see https://create.roblox.com/docs/projects/teleporting#handling-failed-teleports on the Creator Docs
    tpservice:TeleportAsync(17066404164, { player }, teleportOptions)
end)

To set the teleport gui, see the instructions for this method on the documentation:

https://create.roblox.com/docs/reference/engine/classes/TeleportService#SetTeleportGui

I hope this helped :slight_smile:

Thanks for help, I tried your method but the issue still persists and teleports the player from private server to the normal game

Ok I figured out why it didn’t work, the issue was the incorrectly scripted soft shutdown script and I just removed it and fixed the issue.

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