reserve a server of the Dungeon place (place 2) with TeleportService:ReserveServer
save the access code and time
then as players need to join, check the time and if within 8 min allow the player to join (TeleportService:TeleportAsync) otherwise remove the saved access code
I don’t know if this exactly a one-time server teleport, but if I understand correctly, this might be a place to start.
Thank you for answer! I checked what you said, but Google Translate is not working properly(to the link below)… It’s difficult to understand. ( sadness )
I can try to make an example, but it’ll take a bit to put together but here is a small piece of code that I was thinking of if I can’t make an example:
local TeleportService = game:GetService("TeleportService")
local DUNGEON_PLACE_ID = XXXX -- this would be the place id for the place 2
local servers = {}
-- Function to make a server if the player doesn't have one or if it has expired
function MakeServerForPlayer(player)
-- Check if server exists and is within time limit
if servers[player.UserId] == nil or tick() - servers[player.UserId].time > 8 * 60 then
local code = TeleportService:ReserveServer(DUNGEON_PLACE_ID) -- Reserve server
-- Save code and current time
servers[player.UserId] = {
["code"] = code,
["time"] = tick()
}
end
end
-- Join reserved server for player if it exists
function JoinServer(player)
-- Check if server exists and is not expired
if servers[player.UserId] ~= nil and tick() - servers[player.UserId].time < 8*60 then
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ReservedServerAccessCode = servers[player.UserId].code -- access code for teleport
-- Teleport to place with options that include access code
local teleportResult = TeleportService:TeleportAsync(
DUNGEON_PLACE_ID,
{player}, -- teleport only host player (could be changed for some party system)
teleportOptions
)
end
end
Note: I just wrote this code and it is untested, so it may not work as intended but I think it shows the idea.
Let me know if this needs changes or better explanation!
Also: this doesn’t handle errors or failed teleports!
I made a test game to give an example, there are two buttons: the left makes a server, the right joins it. There is a label in between the buttons which shows the access code and the time before a new server is made. There is a remote event to work with the player gui but otherwise the code is the same as my code above.
Here is the .rbxl for the main place (the place 2 is empty expect for a TextLabel) teleport.rbxl (42.0 KB)
(you’ll need to publish both places to test)
Thanks for the nice examples along the way while checking with what you provided!
I was testing with the code you sent me before with time and number restrictions as shown below.
Sorry for the late reply.
And thank you yes35go!
–:::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::
※ Teleport part to try (test)
local TeleportService = game:GetService(“TeleportService”)
local DUNGEON_PLACE_ID = gameid – This will be the place ID of place 2.
local PortalPart = script.Parent
local servers = {}
local TimeLimit = 1 * 60
– Ability to create a server if the player does not have a server or has expired
function MakeServerForPlayer(player)
print(" ok Make ")
– Check if server exists and is within time limit
if servers[player.UserId] == nil or tick() - servers[player.UserId].time > TimeLimit then
local code = TeleportService:ReserveServer(DUNGEON_PLACE_ID) – Reserve server
– Save code and current time
servers[player.UserId] = {
[“code”] = code,
[“time”] = tick(),
[“Use”] = 0,
[“Max”] = 2
}
end
end
– Join the reserved server if there is a player
function JoinServer(player)
– Check that the server exists and has not expired
if servers[player.UserId] ~= nil and tick() - servers[player.UserId].time < TimeLimit then
print(" ok Join ")
local teleportOptions = Instance.new(“TeleportOptions”)
teleportOptions.ReservedServerAccessCode = servers[player.UserId].code – access code for teleport
– Teleport to a location with an option that includes an access code
local teleportResult = TeleportService:TeleportAsync(
DUNGEON_PLACE_ID,
{player}, – Teleport-only host player (may be subject to change in some party systems)
teleportOptions
)
if servers[player.UserId].Use <= servers[player.UserId].Max then
servers[player.UserId].Use = servers[player.UserId].Use + 1
TeleportService:TeleportToPrivateServer( teleportResult )
end
else
MakeServerForPlayer(player)
end
end
local function onTouch( otherPart )
local player = game.Players:GetPlayerFromCharacter( otherPart.Parent )
if player then
print(" #servers: ", #servers )
if #servers <= 0 then
MakeServerForPlayer( player )
JoinServer( player )
else
for _ , GameTime in pairs( servers ) do
if GameTime ~= nil and tick() - GameTime < TimeLimit then
JoinServer( player )
else
MakeServerForPlayer( player )
JoinServer( player )
end
end
end
end
end
PortalPart.Touched:Connect( onTouch )
Thanks for the nice examples along the way while checking with what you provided!
I thought this answer would be helpful to others, so I checked it as a solution.
Of course, the best solution is in the comments below with instructions on how to use it.