Serverlist and join by code

hello guys ive got a serverlist system and its working well. but ive made for every server an simple code beside the accessCode. the accesscode is long and i wanted to make an code to use it to join from code i did this = ```


local function generateNewSimpleID()
	local idLength = 8

	for count = 1, idLength, 1 do
		local randomNumber = RNGesus:NextInteger(0,15)
		if randomNumber > 9 then
			randomNumber = convertToHex(randomNumber)
		else 
			randomNumber = tostring(randomNumber)
		end
		if count == 1 then
			simpleID = randomNumber
		else
			simpleID = simpleID .. randomNumber
		end

	end
	print("New ID created! ID: "..simpleID)
end

but idk acctually how to make joining from code beside the accessCode so they can both work together. or how can i replace the genereated acessCode from roblox and put my simple code


local function teleportPlayer(player, isNewServer, requestedServer)
	
	print("Request received")
	local teleportOptions = Instance.new("TeleportOptions")
	if isNewServer == false then
		print("Player wants to teleport to reserved server!")
		print(requestedServer)
		teleportOptions.ReservedServerAccessCode = requestedServer
	end
	local playerArray = {
		player
	}
	if isNewServer == true then
		if requestedServer:len() < 3 then
			warn("New server name is less than 3 characters!")
requestedServer = player.Name.."'s Server"
		elseif requestedServer:len() > 16 then
			warn("New server name is longer than 16 characters!")
			return "TooLong"
		end
		--if not player:IsInGroup(16892251) then warn("Player is not allowed to create a server! They're not in the group") return "NotInGroup" end
		print("New server created!")
		--initMessageResponse()
		requestedServer = game:GetService("TextService"):FilterStringAsync(requestedServer, player.UserId) -- Just in case a cheeky exploiter tries to make a server and bypass client sided filtering
		requestedServer = requestedServer:GetNonChatStringForBroadcastAsync()
		local counter = 0
		repeat
			wait(1)
			counter += 1
		until requestedServer ~= "" or counter > 5
		if requestedServer == "" or requestedServer == nil then
			warn("Failed to create a new server! Name filtering took too long!")
			return false
		end
		teleportOptions.ShouldReserveServer = true
		local success, tpResult = safeTP(serverPlaceID, playerArray, teleportOptions)
		local newServerInfo = {
			serverName = requestedServer,
			hostName = player.Name,
			hostID = player.UserId,
			accessCode = tpResult.ReservedServerAccessCode
		}
		print(newServerInfo.serverName)
		print(newServerInfo.hostName)
		print(newServerInfo.hostID)
		print(newServerInfo.accessCode)
		print("Number of listings in ServerListings folder:", #repStorage.ServerDropbox.ServerListings:GetChildren())
		
		if success then
			newServerInfo = httpServ:JSONEncode(newServerInfo)
			accessCodes:SetAsync(tpResult.PrivateServerId, newServerInfo)
		else
			return false
		end
		
	else
		local success, result = safeTP(serverPlaceID, playerArray, teleportOptions)
		if success then
			return true
		else
			return false
		end
	end
end

i want to know how to use generated accessCode with my generated code together. or how to replace my generated code with the accessCode so the acessCode be the generaeted code

You could make a table with all the server information stored on it and have the user make their own access code which can be used to access this server using everything else you have made.

You could then use for loops to find the server based on the generateNewSimpleID function.
Check if the inputted accessCode is matching the SimpleID and then allow the player to join.

If I have missed what you meant, let me know, elsewise, something along the description of what I have said should work out.