Is there a way to teleport a player back to a reserved server?
this in case a player disconnects, the case is that a server is reserved and then the players join with the reserved code
this way works and they are teleported, but i tried to make if a player disconnects, the server code is saved to be able to reconnect like this:
local dss = game:GetService("DataStoreService")
local rejoincodedata = dss:GetDataStore("rejoincodedata")
local ts = game:GetService("TeleportService")
game.Players.PlayerAdded:Connect(function(plr)
local codevalue = Instance.new("StringValue", plr)
codevalue.Name = "RejoinCode"
if rejoincodedata:GetAsync(plr.UserId) ~= nil then
codevalue.Value = rejoincodedata:GetAsync(plr.UserId)
end
if codevalue ~= nil or codevalue ~= "" then
print("Code found")
local popup = plr.PlayerGui.Rejoin.Frame:Clone()
popup.Parent = plr.PlayerGui.Rejoin
popup.Visible = true
popup.Yes.MouseButton1Click:Connect(function()
local player = {}
table.insert(player, plr)
ts:TeleportToPrivateServer(12189598524, codevalue.Value, player)
end)
popup.No.MouseButton1Click:Connect(function()
popup:Destroy()
end)
else
print("no code")
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
rejoincodedata:SetAsync(plr.UserId, plr.RejoinCode.Value)
end)
this almost works but at the moment of teleport it doesn’t teleport because “Attempted
to teleport to a restricted server”
what can i do?