You can write your topic however you want, but you need to answer these questions:
- 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.
- 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?
- 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)