Hi, I’m trying to do a simple server hub system using only MessagingService, it mostly works but I got stuck on the part of deleting the servers.
Hub code:
MessagingService:SubscribeAsync("ServerShutdown", function(serverEncoded: ServerInfo)
print("Got new servershutdown event")
print(serverEncoded)
print(serverEncoded.code)
local server = HttpService:JSONDecode(serverEncoded)
print(server)
print(server.code)
local index = ServerToIndex[server.code]
local NewServers = table.clone(Servers:get())
table.remove(NewServers, index)
ServerToIndex[server.code] = nil
Servers:set(NewServers)
print("Should be done!")
end)
Server code:
if not RunService:IsStudio() then
game:BindToClose(function()
MessagingService:PublishAsync("ServerShutdown", HttpService:JSONEncode({
code = ServerCode,
}))
task.wait(10)
end)
end
The problem here is that when the server is closing (and only then, all other events work normally), the message gets to the hub but server.code is nil, I have checked and the table does exist. Since I can’t test the game on Roblox studio I have written simple code to get the contents of the table on the console, but that ends up printing nothing.
for _, v in pairs(server) do
print(v)
end