I want to teleport the player into a reserved server and send the reserved server the data it needs to use in order to create the game. How would I do that with MemoryStoreService (it needs to be server-side because the information is important). Teleport service’s built-in method won’t work in that case. I found multiple posts but it doesn’t fully answer my question. Thanks for helping!
Yeah, using MemoryStoreService is the way to go for sure. When you create the reserved server, you get a private server ID which can be obtained in the receiving server as well. So, an implementation could look like this:
-- 000000000 is the place ID to make a reserved server for.
local accessCode, serverId = TeleportService:ReserveServer(000000000)
-- accessCode is the code to teleport, serverId is the private server's ID.
local MemoryStoreMap = MemoryStoreService:GetSortedMap("ExampleName")
-- set your data here
MemoryStoreMap:SetAsync(serverId, {
["your"] = "data",
["example"] = true
}, 300)
-- 300 second timeout should be enough; you only need the data once.
Then on the reserved server you could do something like this:
local MemoryStoreMap = MemoryStoreService:GetSortedMap("ExampleName")
local data = MemoryStoreMap:GetAsync(game.PrivateServerId)
You might also want to add some checks to ensure the data fetch doesn’t fail, and you might also want to make the system give default data for studio tests.
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.