So I have this code:
local userIdJoiningReservedServerIdStore = game:GetService('DataStoreService'):GetDataStore('UserIdJoiningReservedId')
local jobIdToReservedServerIdStore = game:GetService('DataStoreService'):GetDataStore('JobIdToReservedServerId')
local function getTeleportInfoForUsername(username)
local userId = game.Players:GetUserIdFromNameAsync(username)
if not userId then
return false, 'User by name '..username..' does not exist. Did you type the name wrong?'
end
local success, errorMsg, placeId, jobId = game['Teleport Service']:GetPlayerPlaceInstanceAsync(userId)
if not success then
return false, errorMsg
end
local reservedServerId = jobIdToReservedServerIdStore:GetAsync(jobId)
if not reservedServerId then
return true, 'Success', {
reservedServerId = nil,
placeId = placeId,
jobId = jobId
}
end
return true, 'Success', {
reservedServerId = reservedServerId,
placeId = placeId,
jobId = jobId
}
end
local function teleportPlayerToReservedServer(player, reservedServerId, placeId)
userIdJoiningReservedServerIdStore:SetAsync(tostring(player.UserId), {
reservedServerId = reservedServerId,
placeId = placeId,
time = os.time()
})
game['Teleport Service']:TeleportToPrivateServer(placeId, reservedServerId, {player})
end
local function teleportPlayerToUsername(player, username)
local success, errorMsg, teleportInfo = getTeleportInfoForUsername(username)
if not success then
return errorMsg
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
local tp = teleportPlayerToUsername(player, msg) --[[ im lazy im gonna change this later]]
print(tostring(tp))
end)
end)
but how c ould I create a new reversed server and save it in the datastore? (I got this code from the dev forum/hub)
