local Part = script.Parent
local TpService = game:GetService("TeleportService")
local Access = TpService:ReserveServer(17884687093)
local Players = {}
local Active = true
Part.Touched:Connect(function(Hit)
if Hit.Name == "HumanoidRootPart" then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player and Active then
Active = false
table.insert(Players, Player)
TpService:TeleportToPrivateServer(17884687093, Access, Players)
Players = {}
wait(10)
Active = true
end
end
end)
Problem
When I test this with my alt, my alt was able to join me to “17884687093” (which is a place inside of my game/experience).
The problem doesn’t happen if I teleport to the place with my alt and then teleport to the place with my main on a new server (Joining the game then teleporting after my alt teleports on a brand new server)!! Why?? How do I fix this??
I’m very confused. This advice should NOT be used. And it makes no sense that it “fixed” your issue, which was already rather vague in the first place.
Every time you call TeleportService:ReserveServer(PlaceId) it is creating a NEW Reserved server access code. Touched events are notorious for multiple fires and they fire for every part that is touching at that instant, so this is creating a huge amount of Reserved server codes for no reason.
If I understand you correctly, you wish to make a system that SAVES the reserved server code and then teleports you to that server each time.
If so, the Reference code for the API Documentation on TeleportService:ReserveServer() literally shows you how to do so, and join with saying “reserved” in chat.
Code from the API Docs verbatim:
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetGlobalDataStore()
-- Get the saved code
local code = dataStore:GetAsync("ReservedServer")
if typeof(code) ~= "string" then -- None saved, create one
code = TeleportService:ReserveServer(game.PlaceId)
dataStore:SetAsync("ReservedServer", code)
end
local function joined(player)
player.Chatted:Connect(function(message)
if message == "reserved" then
TeleportService:TeleportToPrivateServer(game.PlaceId, code, { player })
end
end)
end
Players.PlayerAdded:Connect(joined)
That entirely blidesides my point, this is a poor solution that will create wasted resources for Roblox every time a player touches that part. Even if it’s once per player, you only need one reserved server, permanently, unless otherwise stated, in this instance.
Your suggestion is still poor, if not wrong, practice, and as such, is considered poor, if not wrong, advice.