while game.Players:FindFirstChild(player.Name) do
local success, errorMessage = pcall(function()
-- lets get serverDataStore, and that is the serverAccessCode
local serverAccessCode = serverDataStore:GetAsync(friendId) -- who we're joining
local tpData={
ReservedServerCode=serverAccessCode
}
print(serverAccessCode)
--TeleportService:TeleportToPlaceInstance(17503907776, serverAccessCode, player, nil, tpData)
-- lets try using TeleportAsync, instead of TeleportToPlaceInstance, while still teleporting the player to serverAccessCode
local tpOptions=Instance.new("TeleportOptions")
--tpOptions.ReservedServerAccessCode=serverAccessCode
tpOptions.ServerInstanceId=serverAccessCode
tpOptions:SetTeleportData(tpData)
TeleportService:TeleportAsync(17503907776, {player}, tpOptions)
end)
if success then
print("Successfully teleported", player.Name)
else
warn("TeleportToPlaceInstance failed:", errorMessage)
end
wait(math.random(4,6))
end
This is the script used when someone is making a server:
local placeId = 17503907776
--local id,serverAccessCode=game:GetService("TeleportService"):ReserveServer(placeId)
while true do
-- lets use teleportToPLace instance instead.
-- local tpData={
-- ReservedServerCode=
-- }
local tpOptions=Instance.new("TeleportOptions")
--tpOptions:SetTeleportData(tpData)
tpOptions.ShouldReserveServer=true
-- lets use teleportAsync to teleport to a private server
game:GetService("TeleportService"):TeleportAsync(placeId,{plr},tpOptions)
wait(7)
end
But how do people like MiniToon do it (like the build mode in Piggy)?
By the way the first teleport works its just that the second one - where a different user wants to teleport to the same player with the same access code - does not work.
I figured out the solutions. A day of my life wasted because of misunderstanding. Its my fault sorry guys for wasting yall’s time.
Basically I shouldn’t have did:
tpOptions.ShouldReserveServer=true
The reason why I did that is because I thought if it was false, when a player would want to make their own server it would teleport them to the same one of the already existing one. This is not the case
Good job on finding the solution! Don’t feel bad about it, though, the devforum is mainly used by people to get help, anyways. You’re not wasting anyones time Happy scripting!
Nvm, it does not work
The joining friends thing, pretty sure it works.
But now there is another issue - the servers are not private anymore! So I kept joining some random guy’s server!
If anyone knows how to fix this please help. This is the game: