How would I get a reserved server (TeleportService:ReserveServer()
) that is saved across all servers so that I can make a custom VIP server system?
Whenever TeleportService:ReserveServer() is used, the access code is random.
I need a way so that the access code given is the same every time, based on who owns the private server.
An example of a game that uses this is Apocalypse Rising’s VIP server system, where you have to select a map on the VIP server menu, and it always brings you to the same server rather than a different server if a new menu server is created.
If you’re confused on what I mean, i can try to explain it differently, I’m not very good at it :]
I am a bit late, but hopefully this helps you. I did a similar thing before where I “reserved” private servers and accessed them. Of course, others could join them as well. Basically, what you do is reserve a server (using the TeleportService:ReserveServer(PlaceID)
function), you store the server code, and from there you can use it however you like. What I did generate a random 32-character code and saved the teleport code in a DataStore that was linked to the randomly generated code. Here is a sample of my code:
function ReserveNewServer(Player)
local Code = TeleportService:ReserveServer(PlaceId)
local KeyName = GenerateRandomCode(32, {5, 14, 23, 30})
local Success, ErrorMessage = pcall(function()
ReservedServerNamesDataStore:SetAsync(KeyName, Code)
ReservedServersDataStore:SetAsync(KeyName, {Owner = Player.UserId})
DataStoreService:GetOrderedDataStore(tostring(Player.UserId).."-ReservedServers"):SetAsync(tostring(KeyName), os.time())
end)
if Success then
-- Do stuff
end
end
And here is a code sample for joining said server:
local TeleportOptions = Instance.new("TeleportOptions")
TeleportOptions.ReservedServerAccessCode = Code
TeleportService:TeleportAsync(PlaceId, {Player}, TeleportOptions)
Those two combined should give you the result you are looking for. Simply, once you reserve a server, you can use the reserved server as much as you like. (I created my game back in 4/5/2020, and the reserved codes still work today). Hopefully this helped.
I figured out a similar way to do it, but thanks! People reading this looking for help might find this useful.
What I did was create a reserved server code that saves to a datastore, the datastore key being the player’s userId, as I wanted to save one for each player.
Teleporting to it then gets the code from the datastore and teleports the player with the access code.