Teleporting to a reserved server gives an error (773, server is restricted)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to create a system similar to Piggy Build Mode where it reserves a server for players.
  2. What is the issue? Include screenshots / videos if possible!
    I can’t access the reserved server whether I use TeleportToPrivateServer or TeleportAsync.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried looking at every post I found. None of theme fixed the issue.
    It is the same universe, and I even tried turning on 3rd party teleports.
    If it helps, here is my code.
local TeleportService = game:GetService("TeleportService")
game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("BuildEvent").OnServerEvent:Connect(function(player, data)
	if data.Type == "Teleport" then
		local code = game:GetService("DataStoreService"):GetDataStore("BuildServerStore"):GetAsync(data.OwnerId)
		print(code)
		if code == nil then 
			code = TeleportService:ReserveServer(game.PlaceId) 
			game:GetService("DataStoreService"):GetDataStore("BuildServerStore"):SetAsync(data.OwnerId,code) 
		end
		local teleportOptions = Instance.new("TeleportOptions")
		teleportOptions.ReservedServerAccessCode = code
		teleportOptions:SetTeleportData({Owner = data.OwnerId})
		TeleportService:TeleportAsync(11369903874, {player}, teleportOptions)
	end
end)

maybe code isn’t nil and the if loop isn’t running

The reason it does that is that when the player first joins, the code should be nil as in the other place, it resets the datastore when it closes.

local DSS = game:GetService("DataStoreService")

game:BindToClose(function()
	game:GetService("DataStoreService"):GetDataStore("BuildServerStore"):RemoveAsync(settings.OwnerId)
end)

Edit: More explanation: If the server already exists and it just creates another code when another player tries to join, and they won’t be in another server.

Just realized I made a mistake.

I need to be using the place’s id here, since it is not the same as game.PlaceId.

local code = TeleportService:ReserveServer(game.PlaceId)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.