I’ve heard of ReservedServers and I’ve tried them but… how could you just get a code (like shown in these pictures) to give to friends?
One method is to retrieve the JobId of the target server.
The player can type the JobId in that TextBox and you can use TeleportService:TeleportToPlaceInstance() with the InstanceId argument being the JobId.
Its too long, I suggest to even make a custom one
Then another possibility is to use SocialService to invite your friends manually.
To be able to join any server, you can create a server list using MessagingService in which I personally used this video to create one before:
What do you mean “custom one”?
he basically means creating a custom jobid for each server. im not sure how to do this with private servers, but you could allow the player to join the other player’s public server through the JobId, though it would be pointless because the player can just join their friend’s server through the server listings.
A custom one is basically an alphanumeric code, With 8 digits should be sufficient , as it provide over 27292 times the amount of human on earth
local dataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore("Servers")
-- get the next available id number
local success, value = pcall(dataStore.IncrementAsync, dataStore, "Id")
if success == false then ... end
-- convert the number to hex
local serverId = string.format("%X", value)
print("Server ID", serverId)
-- now lets save the serverid so we know what reservedServerAccessCode it corresponds with
local reservedServerAccessCode = ...
-- save the server id as a key and the reservedServerAccessCode as a value
local success, value = pcall(dataStore.SetAsync, dataStore, serverId, reservedServerAccessCode)
-- now to teleport someone to a server
local success, reservedServerAccessCode = pcall(dataStore.GetAsync, dataStore, serverId)
if reservedServerAccessCode == nil then
print("server does not exist")
end
https://developer.roblox.com/en-us/api-reference/function/TeleportService/TeleportToPrivateServer
in the code above i convert the id to a hex but its possible to use all characters in the alphabet when you convert your id to reduce character count
this video will show you how to do that