I hope this is the right category
Hello devs,
Recently I discovered another way of saving teleport data, as I’m having a lot of trouble with TeleportOptions. And I wonder whether is it good to use this to save data
First of all, if you haven’t know already, TeleportService:ReserveServer
returns the access code to the ReservedServer AND the PrivateServerId for the reserved server. We can write this to get both :
local TPS = game:GetService(“TeleportService”)
local PlaceId = 12345
local code, serverId = TPS:ReserveServer(PlaceId)
We can get the ServerId by adding another variable to retrieve it.
Now, we can use a GlobalDataStore to save the data, and that is what I’m trying to do! (To be simple, I did not add the code to handle possible fails, but you are supposed to do it)
local DSS = game.DataStoreService
local ServerIdStore = DSS:GetGlobalDataStore(“ServerIdStore”)
local data = {}
ServerIdStore:SetAsync(tostring(ServerId), data)
And to retrieve data, we can get data using the Server’s PrivateServerId, which returns a string if the server is a Reserved Server, and we should remove the data after we retrieved it :
local DSS = game.DataStoreService
local ServerIdStore = DSS:GetGlobalDataStore(“ServerIdStore”)
local TeleportData = ServerIdStore:GetAsync(game.PrivateServerId)
ServerIdStore:RemoveAsync(game.PrivateServerId)
And that’s the way
What do you think about this way to save data?