How can I tell a game what server type it is?

I’ve a lobby and I have three types of servers: Practice, AI League, and Player League servers, I have a reservedserver script function that saves a datastore with all server tables (each table is {servername then servercode}) .

I want to be able to list server names from inside the game, however when I go through the server list, the PrivateServerId isn’t the same as the reserved code. Is there another way to tell the server what its name is? I wanna do this because league servers I wish to have replays play by default, and practice servers shouldn’t (because it’s for practice).

I do not completely understand what you’re saying, but what I think you want to do is:
Go through the table with the server name + server id.

local Table = {
    Practice = 1234567;
    AI League = 1234568;
    Player Leage = 1234569
}

then you will go through the names and ids with a for loop;

for name,id in pairs(Table) do
    print("The server name is: "..name..", with the id: "..tostring(id))
end

Not really, what I have is like, practice servers 1-12, league servers 1-6 (for AI and Players).

What I do is every time a person requests to join say AI Server 3 I check the datastore, if the datastore is nil, then it makes a newdata store with the data of {{“AI3”,(insert server reserve code here)}}. If it isn’t nil I add onto the datastore, doing this. table.insert(datatable,{“AI3”,(insert server reserve code here)}).

As example:

image

but when you load into a server, it tries to read this!

image

However, the data doesn’t match whatsoever, which makes 0 sense because on the wiki, it says the Reserved code is the servers PrivateServerId which it isn’t.

image

If this still doesn’t make sense I will go into more depth if needed.

In Hockey World I transfer this information through the player teleportation and when the player joins the game server it will fire a remote to the server notifying the server what the server was, and then I close a debounce so that it can’t be fired again in that session to prevent exploiters, and it cannot be exploited because no one can inject synapse before the game loads

Example Code:

Script in lobby:

	local TeleportData = {
		"Practice",
		ServerNumber
	}
	TeleportService:TeleportToPrivateServer(PlaceId, ServerCode, {Player}, nil, TeleportData)

Server Script in game server: (Sorry kinda messy lol)

game:GetService("ReplicatedStorage").InitialData.OnServerEvent:Connect(function(Player, Data)
	if game:GetService("ReplicatedStorage").GotData.Value == false then
		game:GetService("ReplicatedStorage").GotData.Value = true
		local ServerType = Data[1]
		local ServerNumber = Data[2]
		game:GetService("ReplicatedStorage").ServerType.Value = ServerType
		game:GetService("ReplicatedStorage").ServerNumber.Value = ServerNumber
		print(ServerType, ServerNumber)
	end
end)

Local script inside game server: (Located inside of ReplicatedFirst)

--Services
local TeleportService = game:GetService("TeleportService")

function OnTeleportReceived(CustomLoadingScreen, TeleportData)
	--Values
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local GotData = ReplicatedStorage:WaitForChild("GotData")
	
	if GotData.Value == false then
		if TeleportData then
		
			--Remotes
			local InitialData = ReplicatedStorage:WaitForChild("InitialData")
			
			InitialData:FireServer(TeleportData)
		end
	end
end

TeleportService.LocalPlayerArrivedFromTeleport:Connect(OnTeleportReceived)
1 Like

So,

  1. You create a custom Private Server,
  2. You teleport specific players to this server

I am now just confused why it wouldn’t work.
Could you show a bit more of your code as I don’t get where you got servertotpto got from and if the first/last code is inside a function.

Though, I think the issue lays inside the getservername function.

I did this before actually, it was the first thing I did, but people started using the game metatable to alter the remote event not to fire by making it wait like 9999+. So thats why I wanna use this so the clients can’t alter that.

I was doing more research and I found out you can get teleportdata without it being filtered on the server with player:GetJoinData(). I don’t know how while searching on google “transfer data between roblox servers” that didn’t show up, but it works I guess. ¯_(ツ)_/¯