How do delete all inactive/dead Reserved Servers from Table=

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

Im basically trying to make a Lobby system where you can create your own Servers.

  1. What is the issue? Include screenshots / videos if possible!

My issue is that i ran into another problem while making it. How would you detect when a Reserved Server shutsdown. And then remove it from my Table/Servers list?

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I did some research here and found some solution where you can use the ā€œDataStoreServiceā€. But im not sure if this is that good. Because i feel like calling it when creating / removing servers will cause it to queue

This is my server creating system atm:

– // SERVER

local RECIEVE = game.ReplicatedStorage:FindFirstChild("EVENTS").RECIEVE
local CREATE = game.ReplicatedStorage:FindFirstChild("EVENTS").CREATE_SERVER
local TELEPORT = game.ReplicatedStorage:FindFirstChild("EVENTS").TELEPORT
local SERVICE = game:GetService("TeleportService")


local function GET_ICON(KEY)
	return game.Players:GetUserThumbnailAsync(
		KEY,
		Enum.ThumbnailType.AvatarBust,
		Enum.ThumbnailSize.Size420x420
	)
end

local function CREATE_NEW_SERVER()
	local CODE = SERVICE:ReserveServer(game.PlaceId)
	
	return CODE
end


RECIEVE.OnServerEvent:Connect(function(PLAYER)
	CREATE:FireAllClients("CREATE", {
		["PLAYER"] = PLAYER.Name;
		["STATUS"] = true; -- // SERVER IS ACTIVE / ALIVE
		["PLAYERS"] = 1;
		["CODE"] = CREATE_NEW_SERVER();
		["ICON"] = GET_ICON(PLAYER.UserId)
	})
end)

– // CLIENT INSIDE A SCREENGUI

local CREATE = game.ReplicatedStorage:WaitForChild("EVENTS", true).CREATE_SERVER
local TELEPORT = game.ReplicatedStorage:WaitForChild("EVENTS", true).TELEPORT

CREATE.OnClientEvent:Connect(function(MET, TABLE)
	if MET == "CREATE" then
		local CLONE = game.ReplicatedStorage:WaitForChild("GUIS", true).SERVER_FRAME:Clone()
		CLONE.ICON.Image = TABLE["ICON"]
		CLONE.SERVER_NAME.Text = TABLE["PLAYER"]
		CLONE.PLAYERS.Text = "PLAYERS: " ..TABLE["PLAYERS"].. " / 10"
		CLONE.Name = TABLE["PLAYER"]
		CLONE.SERVER_CODE.Value = TABLE["CODE"]
		if TABLE["STATUS"] == true then
			CLONE.STATUS.Text = "STATUS: RUNNING"
		end
		CLONE.Parent = script.Parent.Frame.ScrollingFrame

		CLONE.TELEPORT.MouseButton1Click:Connect(function()
			TELEPORT:FireServer(CLONE.SERVER_CODE.Value)
			script.Parent.Frame.Visible = false
			script.Parent.TELEPORTING.Visible = true
		end)
	elseif MET == "DELETE" then
		warn("DELETE CALLED")
		warn(TABLE)
		DELETE_SERVER(TABLE)
	end
end)

Send a Msg to the Reserved servers in your table and see if there is a response, If there’s no response from the specific server that means there’s no players in it (Dead Server)

1 Like

I think this should help: this

3 Likes

How would i do that. Should i use ā€œMessagingServiceā€. If so ive never used that before?

1 Like

You can read the documentation @itz_rennox just sent, It has some good examples.

1 Like