I'm trying to create a lobby system using a sql server and http requests. I have the following script and I'm not sure what I'm doing wrong.
function _G.Func.Remote.Data.GetLobbyInfo.OnServerInvoke(player)
local hs = game:GetService("HttpService")
local url = "####" -- Blanked out
local result = hs:GetAsync(url.."m=getLobbyInfo&n="..player.Name, true)
print(result) -- This prints the correct info
local lobbies = _G.Core.Split(result,"-") -- Works as string.split
local lobby = {}
for i,_ in pairs(lobbies) do
result = _G.Core.Split(lobbies[i],"_")
lobby[i].info = {} -- From here it gives me the error.
lobby[i].info["name"] = result[1]
lobby[i].info["host"] = result[2]
lobby[i].info["maxPlayers"] = result[4]
lobby[i].info["state"] = result[5]
lobby[i].info.players = {}
local p = _G.Core.Split(result[3]," ")
for _,v in pairs(p) do
lobby[i].info.players[i] = v
end
end
return lobby
end
Error: attempt to index field '?' (a nil value) (at lobby[i].info = {})
