Shorter access codes from Reserve Server

I have been facing an issue with creating a custom private server system.

The access code for the reserved servers are way too long, I was wondering if there was any way to have shorter ones.

local TS = game:GetService(“TeleportService”)

local Players = game:GetService(“Players”)

local DSS = game:GetService(“DataStoreService”)

local DS = DSS:GetGlobalDataStore()

local accescode = DS:GetAsync(“ReservedServer”)

code = TS:ReserveServer(game.PlaceId)

DS:SetAsync(“ReservedServer”,accescode)

And the access code turn out to be as large as a verse in rapgod.
Is there any way to get shorter access codes?

Is there a reason to have a shorter access code? is it because it’s shown to the player? is it because it’s a private server?

it’s because it’s shown to the player via a GUI that allows them to generate a code and insert one to join a private server. However I understand it being frustrating for some players to have to insert a code larger than 5 characters because automatically stuff like that gets moderated in chat messages.

So is it just server wise? because you could program a system where the player selects people to send the code to, kinda like an invite system. Also, is the code really long every time or is it sometimes short or sometimes long?

It’s always really long, which really is bothersome.

Is the second argument given in :SetAsync is required to be a number or it can be a string?

it can indeed be a string yeah

You can make your own code generator and assign the access code to it in a datastore:

local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetGlobalDataStore()

local function CreateAccessCode()
	local CodeGenerator = require(7594040505) -- Code Generator
	local CodeLength = 9 -- Optional
	local AccessCodeKey = CodeGenerator:p1(CodeLength,0)
	local AccessCode = TS:ReserveServer(game.PlaceId)
	if pcall(function()
		DS:SetAsync(AccessCodeKey,AccessCode)
		end) then
		return AccessCodeKey
	else
		return nil
	end
end

-- This is an extra function, you can edit or remove it.
local function JoinReservedServer(Player, ServerAccessCode)
	local AccessCode
	local success = pcall(function()
		AccessCode = DS:GetAsync(ServerAccessCode)
	end)
	if success then
		pcall(function()
			TS:TeleportToPrivateServer(game.PlaceId,AccessCode,{Player})
		end)
	end	
end
2 Likes

some pcall variables aren’t needed

new code
local function JoinReservedServer(Player, ServerAccessCode)
	local AccessCode
	local success = pcall(function()
		AccessCode = DS:GetAsync(ServerAccessCode)
	end)
	if success then
		pcall(function()
			TS:TeleportToPrivateServer(game.PlaceId,AccessCode,{Player})
		end)
	end	
end
2 Likes

It works the same way…

This is you:
“The function name doesn’t need to be JoinReservedServer, new name: J”

nc (new code isn't needed)
l TS = g:GS("TS")
l P = g:GS("P")
l DSS = g:GS("DSS")
l DS = DSS:GGDS()

l f CAC()
	l CG = r(7) - C G
	l CL = 9 - O
	l ACK = CG:p(CL,0)
	l AC = TS:RS(g.PI)
	i p(f()
			DS:SA(ACK,AC)
		e) t
		r ACK
	e
		r n
	e
e

- T i a e f, y c e o r i.
l f JRS(P, SAC)
	l AC
	l s = p(f()
		AC = DS:GA(SAC)
	e)
	i s t
		p(f()
			TS:TTPS(g.PI,AC,{P})
		e)
	e
e

yea it does work the same way, my point is that you don’t need errormsg, success2, or errormsg2

why use the variables if they aren’t needed

I never changed the names of the variables, I removed three variables

1 Like

I made it print the error messages in my testing script, and I wasn’t sure if this topic owner wanted to print stuff or not, so I removed it, and didn’t think about removing the variables.

well then I’m sorry, just giving advice

1 Like

I was hoping there was a feature that would shorten the codes, but I’m very grateful for this information I’ve learned. Thank you for helping!