How to get the JobID of the place the player teleport from

How would I be able to get the JobID of the last place server the player teleported from. I am doing this cause I im trying to make a game where the player

-Is at A, but teleports to B in a reserve server
-When they teleport from B to A, i want the players to teleport back to the same A server as they previously teleported from. Thus, i Need to JobID of the last previous A server so i can be able to teleport them back to the same one.

HOWEVER, if you guys have a better system on how to do this, please do let me know as I feel like the way im doing this is wrong.

you could send the game.JobId as additional data with the teleport. See this section of the teleporting between places article about sending data with a teleport: Teleporting Between Places | Roblox Creator Documentation

THANK YOU SO MUCH!!

To do this you would need to keep track of the server their on, probably using a DataStore, using their Player/UserID, and then when they leave the server, you would remove them from the DataStore (Unless you have a reason to keep track of a player’s data after they left, but this is a different story).
To get the ServerID of the server their on, you would need to use the ServerScriptService, and set a script that runs on the server which is connected to a client to get the ServerID of their current server. To do this, create a LocalScript inside the StarterPlayerScripts, and add this code:
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local RunService = game:GetService(“RunService”)

local Client = ReplicatedStorage:WaitForChild(“Client”)

local CurrentServer = nil

while not RunService:IsClient() do wait() end
CurrentServer = game.JobId

Client.OnClientEvent:Connect(function(Server)
if RunService:IsClient() then
CurrentServer = Server
else
Client:FireClient(CurrentServer)
end
end)

Now, the script should be connected to the client and the server. To get the ServerID of the current server, you would just need to callscript.Parent.CurrentServer, and to set the ServerID, you would need to call script.Parent:FireServer(ServerID). To do this, you would need to put this script in the ServerScriptService, and call the following code:
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local RunService = game:GetService(“RunService”)

local Client = ReplicatedStorage:WaitForChild(“Client”)

local ServerScriptService = game:GetService(“ServerScriptService”)

local ServerScript = ServerScriptService.ServerScript

ServerScript.OnServerInvoke = function(Player, ServerID)
if RunService:IsServer() then
Client:FireClient(ServerID)
else
return ServerScript.CurrentServer
end
end
</code