I am trying to create a system where you can create a server using reserved servers. There is a secondary place that gets reserved on creation. The game teleports you to that reserved server when it is created. You can then let your friends join your server by giving them a unique, 5 character identifier that is also created for that server. When your friend enters the code into the UI, they are teleported to your server.
I am having two issues. Firstly, I have the error that the DataStore request was added to the queue and if it fills the request will be dropped. Second, I am getting an another error saying "Attempted to teleport to a place that is restricted. (Error Code: 773)
I have been having “Error Code 773” for a while and have suspected that it could be a bug with Roblox and not my code. However I am not entirely sure about this. I have just recently started having issues with the DataStore
Code on the Main server that teleports you to the reserved server:
-- The function that updates the server list so players can join public reserved servers.
function updateServerList()
local pages = serverListDataStore:GetSortedAsync(false, 100)
local pageData = pages:GetCurrentPage()
for i, v in pairs(pageData) do
if v.value == 0 then
reservedServerDataStore:RemoveAsync("ServerId-"..v.key)
serverListDataStore:RemoveAsync(v.key)
end
end
updateServerListEvent:FireAllClients(pageData)
end
-- The code that runs the function above.
while true do
updateServerList()
wait(90)
end
-- The function that creates a reserved server and teleports the player to it
function createServer(player)
local serverCode = getNewServerCode()
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ShouldReserveServer = true
local teleportResult = teleportService:TeleportAsync(placeId, {player}, teleportOptions)
-- The complicated saving of the reserved server.
local serverCodeData = {teleportResult.ReservedServerAccessCode, serverCode, true}
reservedServerDataStore:SetAsync("codeData-"..teleportResult.PrivateServerId, serverCodeData)
reservedServerDataStore:SetAsync("ServerId-"..serverCode, {teleportResult.ReservedServerAccessCode, teleportResult.PrivateServerId})
serverListDataStore:SetAsync(serverCode, 0)
-- The code that cancels the teleport if the player requests
cancelServerCreationEvent.OnServerEvent:Connect(function()
cancelServerCreation(player, teleportResult.PrivateServerId, serverCode)
end)
updateServerList()
end)
-- The function that runs when the server teleportation is being canceled
function cancelServerCreation(player, privateServerId, serverCode)
reservedServerDataStore:RemoveAsync("codeData-"..privateServerId)
reservedServerDataStore:RemoveAsync("ServerId-"..serverCode)
serverListDataStore:RemoveAsync(serverCode)
end
-- The function that looks for the server that is requested by the player
function findServer(player, code)
local serverIdInfo
pcall(function()
serverIdInfo = reservedServerDataStore:GetAsync("ServerId-"..code)
end)
if not serverIdInfo then
local ServerCodeFailedEvent = lobbyEvents:WaitForChild("ServerCodeFailed")
ServerCodeFailedEvent:FireClient(player)
return
end
local accessCode = serverIdInfo[2] or nil
return accessCode
end
-- The function that teleports the player into the server that they requested to join
function joinServer(player, userCode)
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ShouldReserveServer = false
local accessCode = findServer(player, userCode)
if accessCode then
teleportOptions.ReservedServerAccessCode = accessCode
local teleportResult = teleportService:TeleportAsync(placeId, {player}, teleportOptions)
else
local ServerCodeFailedEvent = lobbyEvents:WaitForChild("ServerCodeFailed")
ServerCodeFailedEvent:FireClient(player)
end
end
The code on the server that become reserved
local serverCodeData = reservedServerDataStore:GetAsync("codeData-"..game.PrivateServerId)
function playerJoined(player)
-- The code that removes the player from the server if the server creation got canceled or if there was an issues saving the reserved server in the DataStore
if not serverCodeData then
local currentAllPlayers = playerService:GetPlayers()
pcall(function()
teleportService:TeleportPartyAsync(7034144372, currentAllPlayers, 403)
end)
end
-- The code that updates the amount of players on the server list
if serverCodeData then
serverListDataStore:SetAsync(serverCodeData[2], #playerService:GetPlayers())
end
end
-- The code that deletes the server when the server is empty
game:BindToClose(function()
local serverCode
pcall(function()
serverCode = serverCodeData[2]
reservedServerDataStore:RemoveAsync("codeData-"..game.PrivateServerId)
end)
pcall(function()
reservedServerDataStore:RemoveAsync("ServerId-"..serverCode)
end)
pcall(function()
serverListDataStore:RemoveAsync(serverCode)
end)
end)