How to check if server exists with its job id

yes. how to check if server exists with its job id

If not possible
Would it work to: Send a request to servers with messagin service and check if server job id is stored job id, if so return true, if not return false (Id khow to use mssagin service)

1 Like

You could use MessagingService to contact between different servers with a table of stored ingame JobIds, here’s an example on what you could do.

However you will have to make a function to grab these preferably using RemoteFunctions if you’re trying to get them from the client.

(Keep in mind you’re going to have to make your own system on how to detect when a server is fully inactive/0 players. Unless you dont want to do that then sure.)

This would be inside a ServerScript by the way; (This will not work in STUDIO by the way.)

local MessagingService = game:GetService("MessagingService")
local DatastoreService = game:GetService("DatastoreService")

local ServerInfo = {JobId = game.JobId}
local Ids = {}

local function updateServers()
	pcall(function()
		MessagingService:PublishAsync("ServerId", ServerInfo)
	end)
end

local function serverStart()
	MessagingService:SubscribeAsync("ServerId", function(Data)
		local ourData = Data
		for i, b in pairs(Ids) do
			if b.JobId == ourData.JobId then
				table.remove(Ids, i)
			end
		end
		if not table.find(Ids, ourData) then
			table.insert(Ids, ourData)
		end
	end)
end

spawn(function()
	serverStart()
	while true do
		updateServers()
		task.wait(3)
	end
end)
1 Like

I havent even saw anything
Anyway do you know how to do so

If no API url on https://games.roblox.com/docs suit your needs then yes, MessagingService would be the way to go.

I don’t need that for server list in-game
I need that for my summon system
I need to make it one server choose at time
and Im aware that roblox can error when saving data and that will cause in inf waiting for new summon

That could work too I think

Will it automatically store data from all existing servers?

Yes, you’re going to have to create your own further systems for it to work.

since im a bit stupid (fr)
If I just put this in script
and there 2 servers
It will automatically put these 2 in table?
If yes then this surely helps

Yes, the system uses messaging service which subscribes in each server and updates every 3 seconds, therefore everytime the Server Updates it will send the JobId since its subscribed.

So I tested with friend with 2 servers
and for some reason it seems like servers overriding the data inside
Idk how even it looks like in table (also it has some kind of number inside)
image

Alright I got it I think

This only stores one server (I have no idea how to store more) (Actually I have but then it wont work as I need, I think)

Actually I may use the server in there to be the server to choose so it should work

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.