I was trying to pass the amount of players from teleportPartyAsync() via teleportOptions:SetTeleportData() but none of the methods to get that data worked correctly for me. So I decided to use MemoryStoreService to store the amount of players in a sorted map, with the key being the reserved server’s privateServerId.
Summary (Starting place, server)
local MemoryStoreService = game:GetService("MemoryStoreService")
local playerCount = MemoryStoreService:GetSortedMap("PlayerCount")
local TELEPORT_OPTIONS = Instance.new("TeleportOptions")
TELEPORT_OPTIONS.ShouldReserveServer = true
local privateId , AccessCode = TeleportService:TeleportPartyAsync(14043699970 , Match.Players , TELEPORT_OPTIONS )
playerCount:SetAsync(privateId , count , 10800)
Summary (Destination place, server)
local MemoryStoreService = game:GetService("MemoryStoreService")
local PlayerCount = MemoryStoreService:GetSortedMap("PlayerCount")
game.Players.PlayerAdded:Connect(function(player : Player)
print(game.PrivateServerId)
local maxPlayers = PlayerCount:GetAsync(tostring(game.PrivateServerId) ) -- This line returns an error because game.PrivateServerId = ""
print(maxPlayers)
end)
I’m pretty sure PrivateServerIDs only work when a Player creates a private server inside of your game. Reserving a server is when you want to Create a specific TEMPORARY Private server inside the game. These servers are usually temporary, which is why they aren’t giving a private server ID.
Instead, you can probably try this:
local ServerID = game.JobId
This will give you this servers Specific Server ID.
I think this might be an issue with Roblox Itself. If a function that roblox instructs you to use isn’t working as intended, you can possibly try reporting it as a bug, or looking for any backup features.
I can try re-creating your situation, and figuring out the problem. (Which I will do soon.)
Don’t worry, it turns out that my mistake was thinking that the teleportData field for the function could also take a TeleportOptions instance as an argument, hence why no privateserverID was being added. I ended up using a different function that also allows you to teleport a group of players and use teleportOptions.